class ODFWriter::BookmarkReader
BookmarkReader: find all bookmarks and set name
Attributes
name[RW]
Public Class Methods
new(opts={})
click to toggle source
initialize
# File lib/odf_writer/bookmark_reader.rb, line 38 def initialize(opts={}) @name = opts[:name] end
Public Instance Methods
paths( root, doc)
click to toggle source
get_paths: limit to paths with ancestors 'text '(content.xml) and master-styles (styles.xml)
# 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
Private Instance Methods
scan(node)
click to toggle source
private
# File lib/odf_writer/bookmark_reader.rb, line 68 def scan(node) if name node.attr("text:name") == name.upcase ? [node.attr("text:name")] : [] else [node.attr("text:name")] end end