Class: Mbox::Mail::Headers::Name
- Inherits:
-
Object
- Object
- Mbox::Mail::Headers::Name
- Defined in:
- lib/mbox/mail/headers.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name) ⇒ Name
constructor
A new instance of Name.
- #to_s ⇒ Object (also: #to_str)
- #to_sym ⇒ Object
Constructor Details
#initialize(name) ⇒ Name
Returns a new instance of Name.
37 38 39 40 41 42 43 44 45 |
# File 'lib/mbox/mail/headers.rb', line 37 def initialize (name) name = name.to_s.downcase.gsub('-', '_').to_sym if name.empty? raise ArgumentError, 'cannot pass empty name' end @internal = name end |
Class Method Details
.parse(text) ⇒ Object
31 32 33 34 35 |
# File 'lib/mbox/mail/headers.rb', line 31 def self.parse (text) return text if text.is_a? self new(text) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
47 48 49 |
# File 'lib/mbox/mail/headers.rb', line 47 def == (other) to_sym == Name.parse(other).to_sym end |
#hash ⇒ Object
53 54 55 |
# File 'lib/mbox/mail/headers.rb', line 53 def hash to_sym.hash end |
#to_s ⇒ Object Also known as: to_str
62 63 64 65 66 |
# File 'lib/mbox/mail/headers.rb', line 62 def to_s to_sym.to_s.downcase.gsub('_', '-').gsub(/(\A|-)(.)/) {|match| match.upcase } end |
#to_sym ⇒ Object
57 58 59 |
# File 'lib/mbox/mail/headers.rb', line 57 def to_sym @internal end |