Class: PLOS::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/plos/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Section

Returns a new instance of Section.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/plos/section.rb', line 11

def initialize(node)
  self.id = node.attr("id") if node.attr("id")
  self.type = node.attr("sec-type") if node.attr("sec-type")
  node.xpath('./*').each do |child|
    case child.name
    when "title"
      self.title = child.text
    when "sec"
      self.sections << PLOS::Section.new(child)
    when "fig"
      self.sections << PLOS::Figure.new(child)
    else
      self.body << child.to_s
    end
  end
end

Instance Attribute Details

#bodyObject



28
29
30
# File 'lib/plos/section.rb', line 28

def body
  @body ||= ""
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#sectionsObject



32
33
34
# File 'lib/plos/section.rb', line 32

def sections
  @sections ||= []
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end