Class: Sovren::ContactInformation

Inherits:
Object
  • Object
show all
Defined in:
lib/sovren/contact_information.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#address_line_1Object

Returns the value of attribute address_line_1.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def address_line_1
  @address_line_1
end

#address_line_2Object

Returns the value of attribute address_line_2.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def address_line_2
  @address_line_2
end

#aristocratic_titleObject

Returns the value of attribute aristocratic_title.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def aristocratic_title
  @aristocratic_title
end

#cityObject

Returns the value of attribute city.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def city
  @city
end

#countryObject

Returns the value of attribute country.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def country
  @country
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def first_name
  @first_name
end

#form_of_addressObject

Returns the value of attribute form_of_address.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def form_of_address
  @form_of_address
end

#generationObject

Returns the value of attribute generation.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def generation
  @generation
end

#home_phoneObject

Returns the value of attribute home_phone.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def home_phone
  @home_phone
end

#last_nameObject

Returns the value of attribute last_name.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def last_name
  @last_name
end

#middle_nameObject

Returns the value of attribute middle_name.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def middle_name
  @middle_name
end

#mobile_phoneObject

Returns the value of attribute mobile_phone.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def mobile_phone
  @mobile_phone
end

#postal_codeObject

Returns the value of attribute postal_code.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def postal_code
  @postal_code
end

#qualificationObject

Returns the value of attribute qualification.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def qualification
  @qualification
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def state
  @state
end

#websiteObject

Returns the value of attribute website.



3
4
5
# File 'lib/sovren/contact_information.rb', line 3

def website
  @website
end

Class Method Details

.parse(contact_information) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sovren/contact_information.rb', line 5

def self.parse(contact_information)
  return nil if contact_information.nil?
  result = self.new
  result.first_name = contact_information.css('PersonName GivenName').collect(&:text).join(" ")
  result.middle_name = contact_information.css('PersonName MiddleName').collect(&:text).join(" ")
  result.last_name = contact_information.css('PersonName FamilyName').collect(&:text).join(" ")
  result.aristocratic_title = contact_information.css('PersonName Affix[type=aristocraticTitle]').collect(&:text).join(" ")
  result.form_of_address = contact_information.css('PersonName Affix[type=formOfAddress]').collect(&:text).join(" ")
  result.generation = contact_information.css('PersonName Affix[type=generation]').collect(&:text).join(" ")
  result.qualification = contact_information.css('PersonName Affix[type=qualification]').collect(&:text).join(" ")

  address = contact_information.css('PostalAddress DeliveryAddress AddressLine').collect(&:text)
  result.address_line_1 = address[0] if address.length > 0
  result.address_line_2 = address[1] if address.length > 1
  result.city = contact_information.css('PostalAddress').first.css('Municipality').text rescue nil
  result.state = contact_information.css('PostalAddress').first.css('Region').text rescue nil
  result.postal_code = contact_information.css('PostalAddress').first.css('PostalCode').text rescue nil
  result.country = contact_information.css('PostalAddress').first.css('CountryCode').text rescue nil

  result.home_phone = contact_information.css('Telephone FormattedNumber').first.text rescue nil
  result.mobile_phone = contact_information.css('Mobile FormattedNumber').first.text rescue nil

  result.website = contact_information.css('InternetWebAddress').first.text rescue nil
  result.email = contact_information.css('InternetEmailAddress').first.text rescue nil

  result
end