Class: Puree::Person
Overview
Person resource
Instance Method Summary collapse
-
#affiliation ⇒ Array<String>
Affiliation.
-
#image ⇒ Array<String>
Image.
-
#initialize(endpoint: nil, username: nil, password: nil) ⇒ 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, #created, #get, #modified, #response, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil) ⇒ Person
Returns a new instance of Person.
10 11 12 13 14 15 |
# File 'lib/puree/person.rb', line 10 def initialize(endpoint: nil, username: nil, password: nil) super(api: :person, endpoint: endpoint, username: username, password: password) end |
Instance Method Details
#affiliation ⇒ Array<String>
Affiliation
20 21 22 23 24 25 26 |
# File 'lib/puree/person.rb', line 20 def affiliation path = '//organisation/name/localizedString' xpath_result = xpath_query path affiliations = [] xpath_result.each { |i| affiliations << i.text } affiliations.uniq end |
#image ⇒ Array<String>
Image
31 32 33 34 35 36 37 |
# File 'lib/puree/person.rb', line 31 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
42 43 44 45 46 47 48 |
# File 'lib/puree/person.rb', line 42 def keyword path = '//keywordGroup/keyword/userDefinedKeyword/freeKeyword' xpath_result = xpath_query path data = [] xpath_result.each { |i| data << i.text } data.uniq end |
#metadata ⇒ Hash
All metadata
74 75 76 77 78 79 80 81 82 |
# File 'lib/puree/person.rb', line 74 def o = super o['affiliation'] = affiliation o['image'] = image o['keyword'] = keyword o['name'] = name o['orcid'] = orcid o end |
#name ⇒ Hash
Name
53 54 55 56 57 58 59 60 61 |
# File 'lib/puree/person.rb', line 53 def name data = node 'name' o = {} if !data.nil? && !data.empty? o['first'] = data['firstName'].strip o['last'] = data['lastName'].strip end o end |
#orcid ⇒ String
ORCID
66 67 68 69 |
# File 'lib/puree/person.rb', line 66 def orcid data = node 'orcid' !data.nil? && !data.empty? ? data.strip : '' end |