Class: ODFWriter::BookmarkReader
- Inherits:
-
Object
- Object
- ODFWriter::BookmarkReader
- Defined in:
- lib/odf_writer/bookmark_reader.rb
Overview
BookmarkReader: find all bookmarks and set name
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BookmarkReader
constructor
initialize.
-
#paths(root, doc) ⇒ Object
get_paths: limit to paths with ancestors ‘text ’(content.xml) and master-styles (styles.xml).
Constructor Details
#initialize(opts = {}) ⇒ BookmarkReader
initialize
38 39 40 |
# File 'lib/odf_writer/bookmark_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/bookmark_reader.rb', line 31 def name @name end |
Instance Method Details
#paths(root, doc) ⇒ Object
get_paths: limit to paths with ancestors ‘text ’(content.xml) and master-styles (styles.xml)
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/odf_writer/bookmark_reader.rb', line 47 def paths( root, doc) # find nodes with matching field elements matching [BOOKMARK] pattern nodes = doc.xpath("//*[self::text:bookmark or self::text:bookmark-start]").select{|node| scan(node).present? } # find path for each field paths = nil nodes.each do |node| leaf = {:bookmarks => scan(node)} paths = PathFinder.trail(node, leaf, :root => root, :paths => paths) end #each paths.to_h end |