Sha256: e9f0af169efb02b0b3f5a5eeebe36f6d9a632ea8f482c882feb3b94b84bbb67c

Contents?: true

Size: 752 Bytes

Versions: 25

Compression:

Stored size: 752 Bytes

Contents

module Pupa
  # A list of contact details.
  class ContactDetailList < Array
    # Returns the first postal address within the list of contact details.
    #
    # @return [String,nil] a postal address
    def address
      find_by_type('address')
    end

    # Returns the first email address within the list of contact details.
    #
    # @return [String,nil] an email address
    def email
      find_by_type('email')
    end

    # Returns the value of the first contact detail matching the type.
    #
    # @param [String] a type
    # @return [String,nil] a value
    def find_by_type(type)
      find{|contact_detail|
        contact_detail[:type] == type
      }.try{|contact_detail|
        contact_detail[:value]
      }
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
pupa-0.2.4 lib/pupa/models/contact_detail_list.rb
pupa-0.2.3 lib/pupa/models/contact_detail_list.rb
pupa-0.2.2 lib/pupa/models/contact_detail_list.rb
pupa-0.2.1 lib/pupa/models/contact_detail_list.rb
pupa-0.2.0 lib/pupa/models/contact_detail_list.rb
pupa-0.1.11 lib/pupa/models/contact_detail_list.rb
pupa-0.1.10 lib/pupa/models/contact_detail_list.rb
pupa-0.1.9 lib/pupa/models/contact_detail_list.rb
pupa-0.1.8 lib/pupa/models/contact_detail_list.rb
pupa-0.1.7 lib/pupa/models/contact_detail_list.rb
pupa-0.1.6 lib/pupa/models/contact_detail_list.rb
pupa-0.1.5 lib/pupa/models/contact_detail_list.rb
pupa-0.1.4 lib/pupa/models/contact_detail_list.rb
pupa-0.1.3 lib/pupa/models/contact_detail_list.rb
pupa-0.1.2 lib/pupa/models/contact_detail_list.rb
pupa-0.1.1 lib/pupa/models/contact_detail_list.rb
pupa-0.1.0 lib/pupa/models/contact_detail_list.rb
pupa-0.0.13 lib/pupa/models/contact_detail_list.rb
pupa-0.0.12 lib/pupa/models/contact_detail_list.rb
pupa-0.0.11 lib/pupa/models/contact_detail_list.rb