Class: Puree::XMLExtractor::OrganisationalUnit
Overview
Organisational unit XML extractor.
Instance Method Summary
collapse
Methods included from TypeMixin
#type
Methods inherited from Resource
#created_at, #created_by, #id, #model, #modified_at, #modified_by, #previous_uuids, #uuid
Methods inherited from Base
#xpath_query_for_multi_value, #xpath_query_for_single_value
Constructor Details
Returns a new instance of OrganisationalUnit.
10
11
12
13
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 10
def initialize(xml)
super
setup_model :organisational_unit
end
|
Instance Method Details
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# 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('countries/country')
a.country = country.first.text.strip unless country.empty?
a
end
end
|
#email_addresses ⇒ Array<String>
35
36
37
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 35
def email_addresses
xpath_query_for_multi_value '/emails/email'
end
|
#name ⇒ String?
40
41
42
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 40
def name
xpath_query_for_single_value '/names/name'
end
|
46
47
48
49
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 46
def parent
multiple_parents = parents
multiple_parents.empty? ? nil : multiple_parents.first
end
|
52
53
54
55
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 52
def parents
xpath_result = xpath_query '/parents/parent'
Puree::XMLExtractor::Shared. xpath_result if xpath_result
end
|
#phone_numbers ⇒ Array<String>
58
59
60
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 58
def phone_numbers
xpath_query_for_multi_value '/phoneNumbers/phoneNumber'
end
|
#urls ⇒ Array<String>
63
64
65
|
# File 'lib/puree/xml_extractor/organisational_unit.rb', line 63
def urls
xpath_query_for_multi_value '/webAddresses/webAddress'
end
|