Class: ODFWriter::SectionReader
- Inherits:
-
Object
- Object
- ODFWriter::SectionReader
- Defined in:
- lib/odf_writer/section_reader.rb
Overview
SectionReader: find all sections and set name
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(opts) ⇒ SectionReader
constructor
initialize.
-
#nodes(doc) ⇒ Object
nodes.
-
#sections(doc) ⇒ Object
sections.
Constructor Details
#initialize(opts) ⇒ SectionReader
initialize
38 39 40 |
# File 'lib/odf_writer/section_reader.rb', line 38 def initialize(opts) @name = opts[:name] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
31 32 33 |
# File 'lib/odf_writer/section_reader.rb', line 31 def name @name end |
Instance Method Details
#nodes(doc) ⇒ Object
nodes
56 57 58 |
# File 'lib/odf_writer/section_reader.rb', line 56 def nodes( doc ) doc.xpath(".//text:section").map{|node| [node.attr("text:name"), node] }.to_h end |
#sections(doc) ⇒ Object
sections
47 48 49 |
# File 'lib/odf_writer/section_reader.rb', line 47 def sections( doc ) nodes( doc ).keys end |