Class: Pupa::ContactDetailList

Inherits:
Array
  • Object
show all
Defined in:
lib/pupa/models/contact_detail_list.rb

Overview

A list of contact details.

Instance Method Summary collapse

Instance Method Details

#addressString?

Returns the first postal address within the list of contact details.

Returns:

  • (String, nil)

    a postal address



7
8
9
# File 'lib/pupa/models/contact_detail_list.rb', line 7

def address
  find_by_type('address')
end

#emailString?

Returns the first email address within the list of contact details.

Returns:

  • (String, nil)

    an email address



14
15
16
# File 'lib/pupa/models/contact_detail_list.rb', line 14

def email
  find_by_type('email')
end

#find_by_type(type) ⇒ String?

Returns the value of the first contact detail matching the type.

Parameters:

Returns:



22
23
24
25
26
27
28
# File 'lib/pupa/models/contact_detail_list.rb', line 22

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