Module: Mail::CommonAddress::InstanceMethods
- Defined in:
- lib/mail/fields/common/common_address.rb
Overview
:doc:
Instance Method Summary collapse
- #<<(val) ⇒ Object
-
#addresses ⇒ Object
Returns the address string of all the addresses in the address list.
-
#addrs ⇒ Object
Returns the actual address objects in the address list.
- #default ⇒ Object
-
#display_names ⇒ Object
Returns the display name of all the addresses in the address list.
-
#each ⇒ Object
Allows you to iterate through each address object in the syntax tree.
-
#formatted ⇒ Object
Returns the formatted string of all the addresses in the address list.
-
#group_addresses ⇒ Object
Returns the addresses that are part of groups.
-
#group_names ⇒ Object
Returns the name of all the groups in a string.
-
#groups ⇒ Object
Returns a hash of group name => address strings for the address list.
- #parse(val = value) ⇒ Object
Instance Method Details
#<<(val) ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mail/fields/common/common_address.rb', line 73 def <<(val) case when val.nil? raise ArgumentError, "Need to pass an address to <<" when val.blank? parse(encoded) else parse((formatted + [val]).join(", ")) end end |
#addresses ⇒ Object
Returns the address string of all the addresses in the address list
27 28 29 30 |
# File 'lib/mail/fields/common/common_address.rb', line 27 def addresses list = tree.addresses.map { |a| a.address } Mail::AddressContainer.new(self, list) end |
#addrs ⇒ Object
Returns the actual address objects in the address list
45 46 47 48 |
# File 'lib/mail/fields/common/common_address.rb', line 45 def addrs list = tree.addresses Mail::AddressContainer.new(self, list) end |
#default ⇒ Object
69 70 71 |
# File 'lib/mail/fields/common/common_address.rb', line 69 def default addresses end |
#display_names ⇒ Object
Returns the display name of all the addresses in the address list
39 40 41 42 |
# File 'lib/mail/fields/common/common_address.rb', line 39 def display_names list = tree.addresses.map { |a| a.display_name } Mail::AddressContainer.new(self, list) end |
#each ⇒ Object
Allows you to iterate through each address object in the syntax tree
20 21 22 23 24 |
# File 'lib/mail/fields/common/common_address.rb', line 20 def each tree.addresses.each do |address| yield(address) end end |
#formatted ⇒ Object
Returns the formatted string of all the addresses in the address list
33 34 35 36 |
# File 'lib/mail/fields/common/common_address.rb', line 33 def formatted list = tree.addresses.map { |a| a.format } Mail::AddressContainer.new(self, list) end |
#group_addresses ⇒ Object
Returns the addresses that are part of groups
60 61 62 |
# File 'lib/mail/fields/common/common_address.rb', line 60 def group_addresses groups.map { |k,v| v.map { |a| a.format } }.flatten end |
#group_names ⇒ Object
Returns the name of all the groups in a string
65 66 67 |
# File 'lib/mail/fields/common/common_address.rb', line 65 def group_names # :nodoc: tree.group_names end |
#groups ⇒ Object
Returns a hash of group name => address strings for the address list
51 52 53 54 55 56 57 |
# File 'lib/mail/fields/common/common_address.rb', line 51 def groups @groups = Hash.new tree.group_recipients.each do |group| @groups[group.group_name.text_value] = get_group_addresses(group.group_list) end @groups end |
#parse(val = value) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/mail/fields/common/common_address.rb', line 11 def parse(val = value) unless val.blank? @tree = AddressList.new(val) else nil end end |