Class: PLOS::Reference

Inherits:
Object
  • Object
show all
Includes:
XmlHelpers
Defined in:
lib/plos/reference.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlHelpers

#nodes_to_hash, #parse_node, #tag_value

Constructor Details

#initialize(node) ⇒ Reference

Returns a new instance of Reference.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/plos/reference.rb', line 16

def initialize(node)
  self.id = node.attr("id") if node.attr("id")
  self.label = tag_value(node, "label")
  citation_node = node.search("element-citation")
  if citation_node
    self.type = citation_node.attr("publication-type").value if citation_node.attr("publication-type")
    self.year = tag_value(citation_node, "year")
    self.title = tag_value(citation_node, "article-title")
    self.source = tag_value(citation_node, "source")
    self.volume = tag_value(citation_node, "volume")
    self.first_page = tag_value(citation_node, "fpage")
    self.last_page = tag_value(citation_node, "lpage")
    citation_node.search("name").each do |name_node|
      self.authors << PLOS::Name.new(name_node)
    end
  end
end

Instance Attribute Details

#authorsObject



34
35
36
# File 'lib/plos/reference.rb', line 34

def authors
  @authors ||= []
end

#first_pageObject

Returns the value of attribute first_page.



12
13
14
# File 'lib/plos/reference.rb', line 12

def first_page
  @first_page
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/plos/reference.rb', line 5

def id
  @id
end

#labelObject

Returns the value of attribute label.



6
7
8
# File 'lib/plos/reference.rb', line 6

def label
  @label
end

#last_pageObject

Returns the value of attribute last_page.



13
14
15
# File 'lib/plos/reference.rb', line 13

def last_page
  @last_page
end

#sourceObject

Returns the value of attribute source.



10
11
12
# File 'lib/plos/reference.rb', line 10

def source
  @source
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/plos/reference.rb', line 9

def title
  @title
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/plos/reference.rb', line 8

def type
  @type
end

#volumeObject

Returns the value of attribute volume.



11
12
13
# File 'lib/plos/reference.rb', line 11

def volume
  @volume
end

#yearObject

Returns the value of attribute year.



7
8
9
# File 'lib/plos/reference.rb', line 7

def year
  @year
end