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

Constructor Details

#initializePublication

Returns a new instance of Publication.



7
8
9
# File 'lib/puree/publication.rb', line 7

def initialize
  super(:publication)
end

Instance Method Details

#descriptionArray<String>

Description

Returns:

  • (Array<String>)


14
15
16
17
18
19
20
# File 'lib/puree/publication.rb', line 14

def description
  path = '//abstract/localizedString'
  xpath_result =  xpath_query path
  data_arr = []
  xpath_result.each { |i| data_arr << i.text }
  data_arr
end

#doiString

Digital Object Identifier

Returns:

  • (String)


25
26
27
28
29
# File 'lib/puree/publication.rb', line 25

def doi
  path = '//doi'
  xpath_result =  xpath_query path
  xpath_result ? xpath_result.text : ''
end

#fileArray<Hash>

Supporting file

Returns:

  • (Array<Hash>)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/puree/publication.rb', line 34

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
    doc['mime'] = d.xpath('mimeType').text
    doc['size'] = d.xpath('size').text
    doc['url'] = d.xpath('url').text
    docs << doc
  end
  docs
end

#metadataHash

All metadata

Returns:

  • (Hash)


75
76
77
78
79
80
81
82
83
# File 'lib/puree/publication.rb', line 75

def 
  o = {}
  o['description'] = description
  o['doi'] = doi
  o['file'] = file
  o['subtitle'] = subtitle
  o['title'] = title
  o
end

#subtitleArray<String>

Subtitle

Returns:

  • (Array<String>)


64
65
66
67
68
69
70
# File 'lib/puree/publication.rb', line 64

def subtitle
  path = '//content/subtitle'
  xpath_result =  xpath_query path
  data_arr = []
  xpath_result.each { |i| data_arr << i.text }
  data_arr
end

#titleArray<String>

Title

Returns:

  • (Array<String>)


53
54
55
56
57
58
59
# File 'lib/puree/publication.rb', line 53

def title
  path = '//content/title'
  xpath_result =  xpath_query path
  data_arr = []
  xpath_result.each { |i| data_arr << i.text }
  data_arr
end