Class: PLOS::Section
- Inherits:
-
Object
- Object
- PLOS::Section
- Defined in:
- lib/plos/section.rb
Instance Attribute Summary collapse
- #body ⇒ Object
-
#id ⇒ Object
Returns the value of attribute id.
- #sections ⇒ Object
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(node) ⇒ Section
constructor
A new instance of Section.
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
#body ⇒ Object
28 29 30 |
# File 'lib/plos/section.rb', line 28 def body @body ||= "" end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/plos/section.rb', line 5 def id @id end |
#sections ⇒ Object
32 33 34 |
# File 'lib/plos/section.rb', line 32 def sections @sections ||= [] end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/plos/section.rb', line 6 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/plos/section.rb', line 7 def type @type end |