Class: Puree::XMLExtractor::Organisation
Overview
Organisation XML extractor.
Instance Method Summary
collapse
Methods inherited from Resource
#created, #get_data?, #locale, #modified, #uuid, #xpath_query
Methods inherited from Base
#xpath_query_for_multi_value, #xpath_query_for_single_value
Constructor Details
Returns a new instance of Organisation.
9
10
11
12
|
# File 'lib/puree/xml_extractor/organisation.rb', line 9
def initialize(xml:)
super
@resource_type = :organisation
end
|
Instance Method Details
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/puree/xml_extractor/organisation.rb', line 15
def address
xpath_result = xpath_query '/addresses/classifiedAddress'
data = []
xpath_result.each do |d|
a = Puree::Model::Address.new
street = d.xpath('street').text.strip
a.street = street unless street.empty?
building = d.xpath('building').text.strip
a.building = building unless building.empty?
postcode = d.xpath('postalCode').text.strip
a.postcode = postcode unless building.empty?
city = d.xpath('city').text.strip
a.city = city unless city.empty?
country = d.xpath('country/term/localizedString').text.strip
a.country = country unless country.empty?
data << a
end
data.uniq { |d| d.street }
end
|
#email_addresses ⇒ Array<String>
36
37
38
|
# File 'lib/puree/xml_extractor/organisation.rb', line 36
def email_addresses
xpath_query_for_multi_value '/emails/classificationDefinedStringFieldExtension/value'
end
|
#name ⇒ String?
41
42
43
|
# File 'lib/puree/xml_extractor/organisation.rb', line 41
def name
xpath_query_for_single_value '/name/localizedString'
end
|
46
47
48
49
|
# File 'lib/puree/xml_extractor/organisation.rb', line 46
def organisations
xpath_result = xpath_query '/organisations/organisation'
Puree::XMLExtractor::Shared. xpath_result
end
|
52
53
54
|
# File 'lib/puree/xml_extractor/organisation.rb', line 52
def parent
organisations.first unless organisations.empty?
end
|
#phone_numbers ⇒ Array<String>
57
58
59
|
# File 'lib/puree/xml_extractor/organisation.rb', line 57
def phone_numbers
xpath_query_for_multi_value '/phoneNumbers/classificationDefinedStringFieldExtension/value'
end
|
#type ⇒ String?
62
63
64
|
# File 'lib/puree/xml_extractor/organisation.rb', line 62
def type
xpath_query_for_single_value '/typeClassification/term/localizedString'
end
|
#urls ⇒ Array<String>
67
68
69
|
# File 'lib/puree/xml_extractor/organisation.rb', line 67
def urls
xpath_query_for_multi_value '/webAddresses/classificationDefinedFieldExtension/value/localizedString'
end
|