Class: Puree::XMLExtractor::Person

Inherits:
Resource show all
Defined in:
lib/puree/xml_extractor/person.rb

Overview

Person 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

#initialize(xml:) ⇒ Person

Returns a new instance of Person.



9
10
11
12
# File 'lib/puree/xml_extractor/person.rb', line 9

def initialize(xml:)
  super
  @resource_type = :person
end

Instance Method Details

#affiliationsArray<Puree::Model::OrganisationHeader>



15
16
17
18
# File 'lib/puree/xml_extractor/person.rb', line 15

def affiliations
  xpath_result = xpath_query '//organisation'
  Puree::XMLExtractor::Shared.organisation_multi_header xpath_result
end

#email_addressesArray<String>

Returns:

  • (Array<String>)


21
22
23
# File 'lib/puree/xml_extractor/person.rb', line 21

def email_addresses
  xpath_query_for_multi_value '//emails/classificationDefinedStringFieldExtension/value'
end

#image_urlsArray<String>

Returns:

  • (Array<String>)


26
27
28
# File 'lib/puree/xml_extractor/person.rb', line 26

def image_urls
  xpath_query_for_multi_value '/photos/file/url'
end

#keywordsArray<String>

Returns:

  • (Array<String>)


31
32
33
# File 'lib/puree/xml_extractor/person.rb', line 31

def keywords
  xpath_query_for_multi_value '//keywordGroup/keyword/userDefinedKeyword/freeKeyword'
end

#namePuree::Model::PersonName?

Returns:



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/puree/xml_extractor/person.rb', line 36

def name
  xpath_result = xpath_query '/name'
  if xpath_result
    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

#orcidString?

Returns:

  • (String, nil)


49
50
51
# File 'lib/puree/xml_extractor/person.rb', line 49

def orcid
  xpath_query_for_single_value '/orcid'
end