class Puree::XMLExtractor::OrganisationalUnit
Organisational unit XML extractor.
Public Class Methods
new(xml)
click to toggle source
Calls superclass method
Puree::XMLExtractor::Resource::new
# File lib/puree/xml_extractor/organisational_unit.rb, line 10 def initialize(xml) super setup_model :organisational_unit end
Public Instance Methods
address()
click to toggle source
@return [Puree::Model::Address]
# File lib/puree/xml_extractor/organisational_unit.rb, line 16 def address xpath_result = xpath_query '/addresses/address' if !xpath_result.empty? a = Puree::Model::Address.new street = xpath_result.xpath('street').text.strip a.street = street unless street.empty? building = xpath_result.xpath('building').text.strip a.building = building unless building.empty? postcode = xpath_result.xpath('postalcode').text.strip a.postcode = postcode unless building.empty? city = xpath_result.xpath('city').text.strip a.city = city unless city.empty? country = xpath_result.xpath('country/term/text') a.country = country.text.strip unless country.empty? a end end
email_addresses()
click to toggle source
@return [Array<String>]
# File lib/puree/xml_extractor/organisational_unit.rb, line 35 def email_addresses xpath_query_for_multi_value '/emails/email' end
name()
click to toggle source
@return [String, nil]
# File lib/puree/xml_extractor/organisational_unit.rb, line 40 def name xpath_query_for_single_value '/name/text' end
parent()
click to toggle source
First parent @return [Puree::Model::OrganisationalUnitHeader, nil]
# File lib/puree/xml_extractor/organisational_unit.rb, line 46 def parent multiple_parents = parents multiple_parents.empty? ? nil : multiple_parents.first end
parents()
click to toggle source
@return [Array<Puree::Model::OrganisationalUnitHeader>]
# File lib/puree/xml_extractor/organisational_unit.rb, line 52 def parents xpath_result = xpath_query '/parents/parent' Puree::XMLExtractor::Shared.organisation_multi_header xpath_result if xpath_result end
phone_numbers()
click to toggle source
@return [Array<String>]
# File lib/puree/xml_extractor/organisational_unit.rb, line 58 def phone_numbers xpath_query_for_multi_value '/phoneNumbers/phoneNumber' end
urls()
click to toggle source
@return [Array<String>]
# File lib/puree/xml_extractor/organisational_unit.rb, line 63 def urls xpath_query_for_multi_value '/webAddresses/webAddress' end
Private Instance Methods
combine_metadata()
click to toggle source
Calls superclass method
Puree::XMLExtractor::Resource#combine_metadata
# File lib/puree/xml_extractor/organisational_unit.rb, line 73 def combine_metadata super @model.address = address @model.email_addresses = email_addresses @model.name = name @model.parent = parent @model.parents = parents @model.phone_numbers = phone_numbers @model.type = type @model.urls = urls @model end
xpath_root()
click to toggle source
# File lib/puree/xml_extractor/organisational_unit.rb, line 69 def xpath_root '/organisationalUnit' end