Module: Mail::CommonAddress::InstanceMethods

Defined in:
lib/mail/fields/common/common_address.rb

Overview

:doc:

Instance Method Summary collapse

Instance Method Details

#addressesObject

Returns the address string of all the addresses in the address list



19
20
21
# File 'lib/mail/fields/common/common_address.rb', line 19

def addresses
  tree.addresses.map { |a| a.address }
end

#defaultObject



47
48
49
50
51
52
53
# File 'lib/mail/fields/common/common_address.rb', line 47

def default
  if addresses.length == 1
    addresses[0]
  else
    addresses
  end
end

#eachObject

Allows you to iterate through each address object in the syntax tree



12
13
14
15
16
# File 'lib/mail/fields/common/common_address.rb', line 12

def each
  tree.addresses.each do |address|
    yield
  end
end

#formattedObject

Returns the formatted string of all the addresses in the address list



24
25
26
# File 'lib/mail/fields/common/common_address.rb', line 24

def formatted
  tree.addresses.map { |a| a.format }
end

#group_addressesObject

Returns the addresses that are part of groups



38
39
40
# File 'lib/mail/fields/common/common_address.rb', line 38

def group_addresses
  groups.map { |k,v| v.map { |a| a.format } }.flatten
end

#group_namesObject

Returns the name of all the groups in a string



43
44
45
# File 'lib/mail/fields/common/common_address.rb', line 43

def group_names # :nodoc:
  tree.group_names
end

#groupsObject

Returns a hash of group name => address strings for the address list



29
30
31
32
33
34
35
# File 'lib/mail/fields/common/common_address.rb', line 29

def groups
  @groups = Hash.new
  tree.group_recipients.each do |group|
    @groups[group.group_name.text_value] = get_group_addresses(group.group_list.addresses)
  end
  @groups
end