Sha256: 0fb52e577c5887da6dcb2c64ffb88b45c5a29a6e3e4989c9e7bc8ff8d170c71c

Contents?: true

Size: 1.22 KB

Versions: 50

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8
# frozen_string_literal: true
require 'mail/parsers/address_lists_parser'

module Mail
  class AddressList # :nodoc:
    attr_reader :addresses, :group_names

    # 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 = 'ada@test.lindsaar.net, My Group: mikel@test.lindsaar.net, Bob <bob@test.lindsaar.net>;'
    #  a = AddressList.new(list)
    #  a.addresses    #=> [#<Mail::Address:14943130 Address: |ada@test.lindsaar.net...
    #  a.group_names  #=> ["My Group"]
    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

    def addresses_grouped_by_group
      addresses.select(&:group).group_by(&:group)
    end
  end
end

Version data entries

50 entries across 36 versions & 9 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/mail-2.7.1/lib/mail/elements/address_list.rb