Class: Mail::AddressList
- Inherits:
-
Object
- Object
- Mail::AddressList
- Defined in:
- lib/mail/elements/address_list.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#addresses ⇒ Object
readonly
Returns the value of attribute addresses.
-
#group_names ⇒ Object
readonly
Returns the value of attribute group_names.
Instance Method Summary collapse
- #addresses_grouped_by_group ⇒ Object
-
#initialize(string) ⇒ AddressList
constructor
Mail::AddressList is the class that parses To, From and other address fields from emails passed into Mail.
Constructor Details
#initialize(string) ⇒ AddressList
Mail::AddressList is the class that parses To, From and other address fields from emails passed into Mail.
AddressList provides a way to query the groups and mailbox lists of the passed in string.
It can supply all addresses in an array, or return each address as an address object.
Mail::AddressList requires a correctly formatted group or mailbox list per RFC2822 or RFC822. It also handles all obsolete versions in those RFCs.
list = '[email protected], My Group: [email protected], Bob <[email protected]>;'
a = AddressList.new(list)
a.addresses #=> [#<Mail::Address:14943130 Address: |[email protected]...
a.group_names #=> ["My Group"]
24 25 26 27 28 |
# File 'lib/mail/elements/address_list.rb', line 24 def initialize(string) address_list = Parsers::AddressListsParser.parse(string) @addresses = address_list.addresses.map { |a| Address.new(a) } @group_names = address_list.group_names end |
Instance Attribute Details
#addresses ⇒ Object (readonly)
Returns the value of attribute addresses.
7 8 9 |
# File 'lib/mail/elements/address_list.rb', line 7 def addresses @addresses end |
#group_names ⇒ Object (readonly)
Returns the value of attribute group_names.
7 8 9 |
# File 'lib/mail/elements/address_list.rb', line 7 def group_names @group_names end |
Instance Method Details
#addresses_grouped_by_group ⇒ Object
30 31 32 |
# File 'lib/mail/elements/address_list.rb', line 30 def addresses_grouped_by_group addresses.select(&:group).group_by(&:group) end |