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

#employee_idString?

Returns:

  • (String, nil)


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

def employee_id
  id '/dk/atira/pure/person/personsources/employee'
end

#hesa_idString?

Returns:

  • (String, nil)


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

def hesa_id
  id '/dk/atira/pure/person/personsources/hesastaff'
end

#image_urlsArray<String>

Returns:

  • (Array<String>)


36
37
38
# File 'lib/puree/xml_extractor/person.rb', line 36

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

#keywordsArray<String>

Returns:

  • (Array<String>)


41
42
43
# File 'lib/puree/xml_extractor/person.rb', line 41

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

#namePuree::Model::PersonName?

Returns:



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/puree/xml_extractor/person.rb', line 46

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)


59
60
61
# File 'lib/puree/xml_extractor/person.rb', line 59

def orcid
  xpath_query_for_single_value '/orcid'
end

#scopus_idString?

Returns:

  • (String, nil)


64
65
66
# File 'lib/puree/xml_extractor/person.rb', line 64

def scopus_id
  id '/dk/atira/pure/person/personsources/scopusauthor'
end