Class: Puree::Person
Overview
Person resource
Instance Method Summary collapse
-
#affiliation ⇒ Array<String>
Affiliation.
-
#image ⇒ Array<String>
Image.
-
#initialize ⇒ Person
constructor
A new instance of Person.
-
#keyword ⇒ Array<String>
Keyword.
-
#metadata ⇒ Hash
All metadata.
-
#name ⇒ Hash
Name.
-
#orcid ⇒ String
ORCID.
Methods inherited from Resource
#content, #get, #response, #set_content
Constructor Details
#initialize ⇒ Person
Returns a new instance of Person.
7 8 9 |
# File 'lib/puree/person.rb', line 7 def initialize super(:person) end |
Instance Method Details
#affiliation ⇒ Array<String>
Affiliation
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 |
#image ⇒ Array<String>
Image
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 |
#keyword ⇒ Array<String>
Keyword
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 |
#metadata ⇒ Hash
All metadata
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 |
#name ⇒ Hash
Name
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 |
#orcid ⇒ String
ORCID
60 61 62 63 |
# File 'lib/puree/person.rb', line 60 def orcid data = node 'orcid' !data.nil? && !data.empty? ? data : '' end |