Class: Duxml::Saxer::DocuLiner
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#cursor_stack ⇒ Object
Returns the value of attribute cursor_stack.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#observer ⇒ Object
readonly
Returns the value of attribute observer.
Instance Method Summary collapse
- #attr(name, val) ⇒ Object
- #cursor ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(doc, _observer) ⇒ DocuLiner
constructor
A new instance of DocuLiner.
- #start_element(name) ⇒ Object
- #text(str) ⇒ Object
Constructor Details
#initialize(doc, _observer) ⇒ DocuLiner
Returns a new instance of DocuLiner.
25 26 27 28 29 30 |
# File 'lib/duxml/saxer.rb', line 25 def initialize(doc, _observer) @cursor_stack = [doc] @line = 0 @column = 0 @observer = _observer end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
32 33 34 |
# File 'lib/duxml/saxer.rb', line 32 def column @column end |
#cursor_stack ⇒ Object
Returns the value of attribute cursor_stack.
38 39 40 |
# File 'lib/duxml/saxer.rb', line 38 def cursor_stack @cursor_stack end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
32 33 34 |
# File 'lib/duxml/saxer.rb', line 32 def line @line end |
#observer ⇒ Object (readonly)
Returns the value of attribute observer.
32 33 34 |
# File 'lib/duxml/saxer.rb', line 32 def observer @observer end |
Instance Method Details
#attr(name, val) ⇒ Object
45 46 47 |
# File 'lib/duxml/saxer.rb', line 45 def attr(name, val) cursor[name] = val end |
#cursor ⇒ Object
34 35 36 |
# File 'lib/duxml/saxer.rb', line 34 def cursor cursor_stack.last end |
#end_element(name) ⇒ Object
53 54 55 56 |
# File 'lib/duxml/saxer.rb', line 53 def end_element(name) cursor.add_observer(observer) if observer @cursor_stack.pop end |
#start_element(name) ⇒ Object
40 41 42 43 |
# File 'lib/duxml/saxer.rb', line 40 def start_element(name) cursor.nodes.insert(-1, Duxml::Element.new(name, line, column)) cursor_stack << cursor.nodes.last end |
#text(str) ⇒ Object
49 50 51 |
# File 'lib/duxml/saxer.rb', line 49 def text(str) cursor.nodes.insert(-1, str) end |