class Puree::XMLExtractor::Person
Person
XML extractor.
Public Class Methods
new(xml)
click to toggle source
Calls superclass method
Puree::XMLExtractor::Resource::new
# File lib/puree/xml_extractor/person.rb, line 11 def initialize(xml) super setup_model :person end
Public Instance Methods
affiliations()
click to toggle source
@return [Array<Puree::Model::OrganisationalUnitHeader>]
# File lib/puree/xml_extractor/person.rb, line 17 def affiliations xpath_result = xpath_query '/staffOrganisationAssociations/staffOrganisationAssociation/organisationalUnit' Puree::XMLExtractor::Shared.organisation_multi_header xpath_result if xpath_result end
email_addresses()
click to toggle source
@return [Array<String>]
# File lib/puree/xml_extractor/person.rb, line 23 def email_addresses xpath_query_for_multi_value '/staffOrganisationAssociations/staffOrganisationAssociation/emails/email' end
image_urls()
click to toggle source
@return [Array<String>]
# 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.xpath('url').text.strip end arr.uniq end
keywords()
click to toggle source
@return [Array<String>]
# File lib/puree/xml_extractor/person.rb, line 38 def keywords keyword_group 'userDefinedKeywordContainers' end
name()
click to toggle source
@return [Puree::Model::PersonName, nil]
# 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()
click to toggle source
@return [String, nil]
# File lib/puree/xml_extractor/person.rb, line 56 def orcid xpath_query_for_single_value '/orcid' end
other_names()
click to toggle source
@return [Array<Model::PersonName>]
# 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
Private Instance Methods
combine_metadata()
click to toggle source
Calls superclass method
Puree::XMLExtractor::Resource#combine_metadata
# File lib/puree/xml_extractor/person.rb, line 81 def combine_metadata super @model.affiliations = affiliations @model.email_addresses = email_addresses @model.identifiers = identifiers @model.image_urls = image_urls @model.keywords = keywords @model.name = name @model.orcid = orcid @model.other_names = other_names @model end
xpath_root()
click to toggle source
# File lib/puree/xml_extractor/person.rb, line 77 def xpath_root '/person' end