class FN::Node::Context
Attributes
current[RW]
doc[R]
Public Class Methods
new()
click to toggle source
# File lib/fn/node/context.rb, line 11 def initialize @doc = XML::Document.new @doc.root = @current = FN::Node::Root() end
Public Instance Methods
<<(node)
click to toggle source
# File lib/fn/node/context.rb, line 16 def <<(node) add node @current = node end
add(node)
click to toggle source
# File lib/fn/node/context.rb, line 29 def add(node) @current << node end
inject_at_head(item)
click to toggle source
# File lib/fn/node/context.rb, line 52 def inject_at_head(item) head = @doc.find_first("//begin_document") if head.first? head.first.prev = item else head << item end end
inject_at_page(number) { |self| ... }
click to toggle source
# File lib/fn/node/context.rb, line 61 def inject_at_page(number) old = @current @current = @doc.find_first("//begin_page_ext[@number='#{number}']") or raise "page not found: #{number}. Pages: #{@doc.find('//begin_page_ext').map{|n|n.to_s}.inspect}" yield self @current = old end
pre(item)
click to toggle source
# File lib/fn/node/context.rb, line 44 def pre(item) if @current.first? @current.first.prev = item else @current << item end end
retain_after() { |self| ... }
click to toggle source
# File lib/fn/node/context.rb, line 33 def retain_after old = @current yield self @current = old end
root()
click to toggle source
# File lib/fn/node/context.rb, line 21 def root doc.root end
root?()
click to toggle source
# File lib/fn/node/context.rb, line 25 def root? current == root end
visit(struct, debug = false)
click to toggle source
# File lib/fn/node/context.rb, line 39 def visit(struct, debug = false) root.visit(struct,debug) struct end