Class: Puree::XMLExtractor::Person
Overview
Instance Method Summary
collapse
#identifiers
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
#initialize(xml) ⇒ Person
Returns a new instance of Person.
11
12
13
14
|
# File 'lib/puree/xml_extractor/person.rb', line 11
def initialize(xml)
super
setup_model :person
end
|
Instance Method Details
17
18
19
20
|
# File 'lib/puree/xml_extractor/person.rb', line 17
def affiliations
xpath_result = xpath_query '/staffOrganisationAssociations/staffOrganisationAssociation/organisationalUnit'
Puree::XMLExtractor::Shared. xpath_result if xpath_result
end
|
#email_addresses ⇒ Array<String>
23
24
25
|
# File 'lib/puree/xml_extractor/person.rb', line 23
def email_addresses
xpath_query_for_multi_value '/staffOrganisationAssociations/staffOrganisationAssociation/emails/email'
end
|
#image_urls ⇒ Array<String>
28
29
30
31
32
33
34
35
|
# File 'lib/puree/xml_extractor/person.rb', line 28
def image_urls
xpath_result = xpath_query '/profilePhotos/profilePhoto'
arr = []
xpath_result.each do |i|
arr << i.attr('url').strip
end
arr.uniq
end
|
#keywords ⇒ Array<String>
38
39
40
|
# File 'lib/puree/xml_extractor/person.rb', line 38
def keywords
keyword_group 'userDefinedKeywordContainers'
end
|
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/puree/xml_extractor/person.rb', line 43
def name
xpath_result = xpath_query '/name'
if !xpath_result.empty?
first = xpath_result.xpath('firstName').text.strip
last = xpath_result.xpath('lastName').text.strip
model = Puree::Model::PersonName.new
model.first = first unless first.empty?
model.last = last unless last.empty?
model
end
end
|
#orcid ⇒ String?
56
57
58
|
# File 'lib/puree/xml_extractor/person.rb', line 56
def orcid
xpath_query_for_single_value '/orcid'
end
|
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/puree/xml_extractor/person.rb', line 61
def other_names
xpath_result = xpath_query '/nameVariants/nameVariant/name'
data = []
xpath_result.each do |d|
first = xpath_result.xpath('firstName').text.strip
last = xpath_result.xpath('lastName').text.strip
model = Puree::Model::PersonName.new
model.first = first unless first.empty?
model.last = last unless last.empty?
data << model
end
data.uniq
end
|