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, #created, #get, #modified, #response, #set_content, #uuid

Constructor Details

#initialize(endpoint: nil, username: nil, password: nil) ⇒ Person

Returns a new instance of Person.

Parameters:

  • endpoint (String) (defaults to: nil)
  • optional

    username [String]

  • optional

    password [String]



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

#affiliationArray<String>

Affiliation

Returns:

  • (Array<String>)


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

#imageArray<String>

Image

Returns:

  • (Array<String>)


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

#keywordArray<String>

Keyword

Returns:

  • (Array<String>)


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

#metadataHash

All metadata

Returns:

  • (Hash)


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

#nameHash

Name

Returns:

  • (Hash)


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

#orcidString

ORCID

Returns:

  • (String)


66
67
68
69
# File 'lib/puree/person.rb', line 66

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