Class: OpenPGP::Packet::UserID
- Inherits:
-
OpenPGP::Packet
- Object
- OpenPGP::Packet
- OpenPGP::Packet::UserID
- Defined in:
- lib/openpgp/packet.rb
Overview
OpenPGP User ID packet (tag 13).
Instance Attribute Summary collapse
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from OpenPGP::Packet
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from OpenPGP::Packet
#body, for, #initialize, parse, parse_new_format, parse_old_format, tag
Constructor Details
This class inherits a constructor from OpenPGP::Packet
Instance Attribute Details
permalink #comment ⇒ Object
Returns the value of attribute comment.
404 405 406 |
# File 'lib/openpgp/packet.rb', line 404 def comment @comment end |
permalink #email ⇒ Object
Returns the value of attribute email.
404 405 406 |
# File 'lib/openpgp/packet.rb', line 404 def email @email end |
permalink #name ⇒ Object
Returns the value of attribute name.
404 405 406 |
# File 'lib/openpgp/packet.rb', line 404 def name @name end |
Class Method Details
permalink .parse_body(body, options = {}) ⇒ Object
[View source]
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/openpgp/packet.rb', line 406 def self.parse_body(body, = {}) 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 |
Instance Method Details
permalink #to_s ⇒ Object
[View source]
429 430 431 432 433 434 435 |
# File 'lib/openpgp/packet.rb', line 429 def to_s text = [] text << name if name text << "(#{comment})" if comment text << "<#{email}>" if email text.join(' ') end |
permalink #write_body(buffer) ⇒ Object
[View source]
425 426 427 |
# File 'lib/openpgp/packet.rb', line 425 def write_body(buffer) buffer.write(to_s) end |