Class: Puree::Person
Overview
Person resource
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#affiliation ⇒ Array<Hash>
Affiliation.
-
#email ⇒ Array
Email.
-
#image ⇒ Array<String>
Image URL.
-
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: 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, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) ⇒ Person
Returns a new instance of Person.
11 12 13 14 15 16 17 |
# File 'lib/puree/person.rb', line 11 def initialize(endpoint: nil, username: nil, password: nil, basic_auth: nil) super(api: :person, endpoint: endpoint, username: username, password: password, basic_auth: basic_auth) end |
Instance Method Details
#affiliation ⇒ Array<Hash>
Affiliation
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puree/person.rb', line 24 def affiliation path = '//organisation' xpath_result = xpath_query path data_arr = [] xpath_result.each { |i| data = {} data['uuid'] = i.attr('uuid').strip data['name'] = i.xpath('name/localizedString').text.strip data_arr << data } data_arr.uniq end |
#email ⇒ Array
40 41 42 43 44 45 46 |
# File 'lib/puree/person.rb', line 40 def email path = '//emails/classificationDefinedStringFieldExtension/value' xpath_result = xpath_query path data = [] xpath_result.each { |i| data << i.text } data.uniq end |
#image ⇒ Array<String>
Image URL
51 52 53 54 55 56 57 |
# File 'lib/puree/person.rb', line 51 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
62 63 64 65 66 67 68 |
# File 'lib/puree/person.rb', line 62 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
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/puree/person.rb', line 95 def o = super o['affiliation'] = affiliation o['email'] = email o['image'] = image o['keyword'] = keyword o['name'] = name o['orcid'] = orcid o end |
#name ⇒ Hash
Name
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/puree/person.rb', line 73 def name path = '/name' xpath_result = xpath_query path first = xpath_result.xpath('firstName').text.strip last = xpath_result.xpath('lastName').text.strip o = {} o['first'] = first o['last'] = last o end |
#orcid ⇒ String
ORCID
87 88 89 90 |
# File 'lib/puree/person.rb', line 87 def orcid path = '/orcid' xpath_query_for_single_value path end |