Class: Puree::Publication

Inherits:
Resource show all
Defined in:
lib/puree/publication.rb

Overview

Publication 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) ⇒ Publication

Returns a new instance of Publication.

Parameters:

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

    username [String]

  • optional

    password [String]



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

#descriptionString

Description

Returns:

  • (String)


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

#doiString

Digital Object Identifier

Returns:

  • (String)


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

#fileArray<Hash>

Supporting file

Returns:

  • (Array<Hash>)


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

#metadataHash

All metadata

Returns:

  • (Hash)


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

#subtitleString

Subtitle

Returns:

  • (String)


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

#titleString

Title

Returns:

  • (String)


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