Class: PLOS::Figure

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlHelpers

#nodes_to_hash, #parse_node, #tag_value

Constructor Details

#initialize(node) ⇒ Figure

Returns a new instance of Figure.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/plos/figure.rb', line 14

def initialize(node)
  self.id = node.attr("id")
  self.position = node.attr("position")
  self.label = tag_value(node, "label")
  caption_node = node.search("caption").first
  if caption_node
    self.caption[:title] = tag_value(caption_node, "title")
    self.caption[:body] = tag_value(caption_node, "p")
  end

  graphic_node = node.search("graphic").first
  if graphic_node
    mimetype = graphic_node.attr("mimetype")
    position = graphic_node.attr("position")
    link = graphic_node.attr("xlink:href")
    self.graphic[:mimetype] = mimetype if mimetype
    self.graphic[:position] = position if position
    self.graphic[:link] = link if link
  end

  object_node = node.search("object-id").first
  if object_node
    type = object_node.attr("pub-id-type")
    value = object_node.text
    self.object[:type] = type if type
    self.object[:value] = value if value
  end
end

Instance Attribute Details

#captionObject



43
44
45
# File 'lib/plos/figure.rb', line 43

def caption
  @caption ||= {}
end

#graphicObject



47
48
49
# File 'lib/plos/figure.rb', line 47

def graphic
  @graphic ||= {}
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#labelObject

Returns the value of attribute label.



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

def label
  @label
end

#objectObject



51
52
53
# File 'lib/plos/figure.rb', line 51

def object
  @object ||= {}
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end