class OpenPGP::Packet::UserID
OpenPGP
User ID packet (tag 13).
@see tools.ietf.org/html/rfc4880#section-5.11 @see tools.ietf.org/html/rfc2822
Attributes
comment[RW]
email[RW]
name[RW]
Public Class Methods
parse_body(body, options = {})
click to toggle source
# File lib/openpgp/packet.rb, line 426 def self.parse_body(body, options = {}) case body.read # User IDs of the form: "name (comment) <email>" when /^([^\(]+)\(([^\)]+)\)\s+<([^>]+)>$/ self.new(:name => $1.strip, :comment => $2.strip, :email => $3.strip) # User IDs of the form: "name <email>" when /^([^<]+)\s+<([^>]+)>$/ self.new(:name => $1.strip, :comment => nil, :email => $2.strip) # User IDs of the form: "name" when /^([^<]+)$/ self.new(:name => $1.strip, :comment => nil, :email => nil) # User IDs of the form: "<email>" when /^<([^>]+)>$/ self.new(:name => nil, :comment => nil, :email => $1.strip) else self.new(:name => nil, :comment => nil, :email => nil) end end
Public Instance Methods
to_s()
click to toggle source
# File lib/openpgp/packet.rb, line 449 def to_s text = [] text << name if name text << "(#{comment})" if comment text << "<#{email}>" if email text.join(' ') end
write_body(buffer)
click to toggle source
# File lib/openpgp/packet.rb, line 445 def write_body(buffer) buffer.write(to_s) end