Class: Puree::Publication
Overview
Publication resource
Instance Method Summary collapse
-
#description ⇒ String
Description.
-
#doi ⇒ String
Digital Object Identifier.
-
#file ⇒ Array<Hash>
Supporting file.
-
#initialize(endpoint: nil, username: nil, password: nil) ⇒ Publication
constructor
A new instance of Publication.
-
#metadata ⇒ Hash
All metadata.
-
#subtitle ⇒ String
Subtitle.
-
#title ⇒ String
Title.
Methods inherited from Resource
#content, #created, #get, #modified, #response, #set_content, #uuid
Constructor Details
#initialize(endpoint: nil, username: nil, password: nil) ⇒ Publication
Returns a new instance of Publication.
10 11 12 13 14 15 |
# File 'lib/puree/publication.rb', line 10 def initialize(endpoint: nil, username: nil, password: nil) super(api: :publication, endpoint: endpoint, username: username, password: password) end |
Instance Method Details
#description ⇒ String
Description
20 21 22 23 24 |
# File 'lib/puree/publication.rb', line 20 def description path = '//abstract/localizedString' xpath_result = xpath_query path xpath_result ? xpath_result.text.strip : '' end |
#doi ⇒ String
Digital Object Identifier
29 30 31 32 33 |
# File 'lib/puree/publication.rb', line 29 def doi path = '//doi' xpath_result = xpath_query path xpath_result ? xpath_result.text.strip : '' end |
#file ⇒ Array<Hash>
Supporting file
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/puree/publication.rb', line 38 def file path = '//electronicVersionFileAssociations/electronicVersionFileAssociation/file' xpath_result = xpath_query path docs = [] xpath_result.each do |d| doc = {} # doc['id'] = d.xpath('id').text doc['name'] = d.xpath('fileName').text.strip doc['mime'] = d.xpath('mimeType').text.strip doc['size'] = d.xpath('size').text.strip doc['url'] = d.xpath('url').text.strip docs << doc end docs.uniq end |
#metadata ⇒ Hash
All metadata
75 76 77 78 79 80 81 82 83 |
# File 'lib/puree/publication.rb', line 75 def o = super o['description'] = description o['doi'] = doi o['file'] = file o['subtitle'] = subtitle o['title'] = title o end |
#subtitle ⇒ String
Subtitle
66 67 68 69 70 |
# File 'lib/puree/publication.rb', line 66 def subtitle path = '//content/subtitle' xpath_result = xpath_query path xpath_result ? xpath_result.text.strip : '' end |
#title ⇒ String
Title
57 58 59 60 61 |
# File 'lib/puree/publication.rb', line 57 def title path = '//content/title' xpath_result = xpath_query path xpath_result ? xpath_result.text.strip : '' end |