Sha256: c24edd2ef6ac7cb4eef766554cb3f4314d423770befaef889985e7bf8d645807

Contents?: true

Size: 622 Bytes

Versions: 5

Compression:

Stored size: 622 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

  private

    def find_by_type(type)
      find{|contact_detail|
        contact_detail[:type] == type
      }.try{|contact_detail|
        contact_detail[:value]
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pupa-0.0.5 lib/pupa/models/contact_detail_list.rb
pupa-0.0.4 lib/pupa/models/contact_detail_list.rb
pupa-0.0.3 lib/pupa/models/contact_detail_list.rb
pupa-0.0.2 lib/pupa/models/contact_detail_list.rb
pupa-0.0.1 lib/pupa/models/contact_detail_list.rb