Class: FN::Node::Context
- Inherits:
-
Object
- Object
- FN::Node::Context
- Defined in:
- lib/fn/node/context.rb
Instance Attribute Summary collapse
-
#current ⇒ Object
Returns the value of attribute current.
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Instance Method Summary collapse
- #<<(node) ⇒ Object
- #add(node) ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #inject_at_head(item) ⇒ Object
- #inject_at_page(number) {|_self| ... } ⇒ Object
- #pre(item) ⇒ Object
- #retain_after {|_self| ... } ⇒ Object
- #root ⇒ Object
- #root? ⇒ Boolean
- #visit(struct, debug = false) ⇒ Object
Constructor Details
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
9 10 11 |
# File 'lib/fn/node/context.rb', line 9 def current @current end |
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
8 9 10 |
# File 'lib/fn/node/context.rb', line 8 def doc @doc end |
Instance Method Details
#<<(node) ⇒ Object
16 17 18 19 |
# File 'lib/fn/node/context.rb', line 16 def <<(node) add node @current = node end |
#add(node) ⇒ Object
29 30 31 |
# File 'lib/fn/node/context.rb', line 29 def add(node) @current << node end |
#inject_at_head(item) ⇒ Object
52 53 54 55 56 57 58 59 |
# 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| ... } ⇒ Object
61 62 63 64 65 66 67 |
# 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) ⇒ Object
44 45 46 47 48 49 50 |
# 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| ... } ⇒ Object
33 34 35 36 37 |
# File 'lib/fn/node/context.rb', line 33 def retain_after old = @current yield self @current = old end |
#root ⇒ Object
21 22 23 |
# File 'lib/fn/node/context.rb', line 21 def root doc.root end |
#visit(struct, debug = false) ⇒ Object
39 40 41 42 |
# File 'lib/fn/node/context.rb', line 39 def visit(struct, debug = false) root.visit(struct,debug) struct end |