Class: MailParser::RFC2822::Mailbox

Inherits:
Object
  • Object
show all
Defined in:
lib/mailparser/rfc2822.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(addr_spec, display_name = nil) ⇒ Mailbox

Returns a new instance of Mailbox.



85
86
87
88
89
# File 'lib/mailparser/rfc2822.rb', line 85

def initialize(addr_spec, display_name=nil)
  @addr_spec = addr_spec
  @display_name = display_name || ""
  @comments = []
end

Instance Attribute Details

#addr_specObject (readonly)

Returns the value of attribute addr_spec.



90
91
92
# File 'lib/mailparser/rfc2822.rb', line 90

def addr_spec
  @addr_spec
end

#commentsObject

Returns the value of attribute comments.



91
92
93
# File 'lib/mailparser/rfc2822.rb', line 91

def comments
  @comments
end

#display_nameObject (readonly) Also known as: phrase

Returns the value of attribute display_name.



90
91
92
# File 'lib/mailparser/rfc2822.rb', line 90

def display_name
  @display_name
end

Instance Method Details

#domainObject



96
97
98
# File 'lib/mailparser/rfc2822.rb', line 96

def domain()
  @addr_spec.domain
end

#local_partObject



93
94
95
# File 'lib/mailparser/rfc2822.rb', line 93

def local_part()
  @addr_spec.local_part
end

#to_sObject



99
100
101
102
103
104
105
# File 'lib/mailparser/rfc2822.rb', line 99

def to_s()
  if display_name.empty? then
    "<#{@addr_spec}>"
  else
    "#{@display_name} <#{@addr_spec}>"
  end
end