Class: Puree::Person

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

Overview

Person resource

Instance Method Summary collapse

Methods inherited from Resource

#content, #get, #response, #set_content

Constructor Details

#initializePerson

Returns a new instance of Person.



7
8
9
# File 'lib/puree/person.rb', line 7

def initialize
  super(:person)
end

Instance Method Details

#affiliationArray<String>

Affiliation

Returns:

  • (Array<String>)


14
15
16
17
18
19
20
# File 'lib/puree/person.rb', line 14

def affiliation
  path = '//organisation/name/localizedString'
  xpath_result =  xpath_query path
  affiliations = []
  xpath_result.each { |i| affiliations << i.text }
  return affiliations.uniq
end

#imageArray<String>

Image

Returns:

  • (Array<String>)


25
26
27
28
29
30
31
# File 'lib/puree/person.rb', line 25

def image
  path = '//photos/file/url'
  xpath_result =  xpath_query path
  data = []
  xpath_result.each { |i| data << i.text }
  data.uniq
end

#keywordArray<String>

Keyword

Returns:

  • (Array<String>)


36
37
38
39
40
41
42
# File 'lib/puree/person.rb', line 36

def keyword
  path = '//keywordGroup/keyword/userDefinedKeyword/freeKeyword'
  xpath_result =  xpath_query path
  data = []
  xpath_result.each { |i| data << i.text }
  return data.uniq
end

#metadataHash

All metadata

Returns:

  • (Hash)


68
69
70
71
72
73
74
75
76
# File 'lib/puree/person.rb', line 68

def 
  o = {}
  o['affiliation'] = affiliation
  o['image'] = image
  o['keyword'] = keyword
  o['name'] = name
  o['orcid'] = orcid
  o
end

#nameHash

Name

Returns:

  • (Hash)


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

def name
  data = node 'name'
  o = {}
  if !data.nil? && !data.empty?
    o['first'] = data['firstName']
    o['last'] = data['lastName']
  end
  o
end

#orcidString

ORCID

Returns:

  • (String)


60
61
62
63
# File 'lib/puree/person.rb', line 60

def orcid
  data = node 'orcid'
  !data.nil? && !data.empty? ? data : ''
end