Class: ODFWriter::TextReader
- Inherits:
-
FieldReader
- Object
- FieldReader
- ODFWriter::TextReader
- Defined in:
- lib/odf_writer/text_reader.rb
Overview
TextReader: find all texts and set name
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ TextReader
constructor
initialize.
-
#paths(file, doc) ⇒ Object
paths.
Constructor Details
#initialize(opts = {}) ⇒ TextReader
initialize
38 39 40 |
# File 'lib/odf_writer/text_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/text_reader.rb', line 31 def name @name end |
Instance Method Details
#paths(file, doc) ⇒ Object
paths
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/odf_writer/text_reader.rb', line 47 def paths( file, doc) # find nodes with matching field elements matching [FIELD] pattern nodes = doc.xpath("//text()").select{|node| scan(node).present? } # find path for each field paths = nil nodes.each do |node| leaf = {:texts => scan(node)} paths = PathFinder.trail(node, leaf, :root => file, :paths => paths) end #each paths.to_h end |