Class: ReDuxml::ResolverClass
- Inherits:
-
Ox::Sax
- Object
- Ox::Sax
- ReDuxml::ResolverClass
- Defined in:
- lib/re_dux.rb
Constant Summary collapse
- COND_ATTR_NAME =
'if'
- REF_ATTR_NAME =
'ref'
Instance Attribute Summary collapse
-
#cursor_stack ⇒ Object
readonly
Returns the value of attribute cursor_stack.
-
#dead ⇒ Object
readonly
Returns the value of attribute dead.
-
#e ⇒ Object
readonly
Returns the value of attribute e.
Instance Method Summary collapse
- #attr(name, val) ⇒ Object
- #cursor ⇒ Object
- #end_element(name) ⇒ Object
-
#initialize(logic) ⇒ ResolverClass
constructor
A new instance of ResolverClass.
- #start_element(name) ⇒ Object
- #text(str) ⇒ Object
Constructor Details
#initialize(logic) ⇒ ResolverClass
Returns a new instance of ResolverClass.
19 20 21 22 |
# File 'lib/re_dux.rb', line 19 def initialize(logic) @cursor_stack = [] @e = ReDuxml::Evaluator.new(logic) end |
Instance Attribute Details
#cursor_stack ⇒ Object (readonly)
Returns the value of attribute cursor_stack.
15 16 17 |
# File 'lib/re_dux.rb', line 15 def cursor_stack @cursor_stack end |
#dead ⇒ Object (readonly)
Returns the value of attribute dead.
15 16 17 |
# File 'lib/re_dux.rb', line 15 def dead @dead end |
#e ⇒ Object (readonly)
Returns the value of attribute e.
15 16 17 |
# File 'lib/re_dux.rb', line 15 def e @e end |
Instance Method Details
#attr(name, val) ⇒ Object
34 35 36 |
# File 'lib/re_dux.rb', line 34 def attr(name, val) cursor[name] = val end |
#cursor ⇒ Object
24 25 26 |
# File 'lib/re_dux.rb', line 24 def cursor @cursor_stack.last end |
#end_element(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/re_dux.rb', line 42 def end_element(name) case when cursor.if? cursor.remove_attribute(COND_ATTR_NAME) when cursor.respond_to?(:instantiate) # target = cursor.instantiate # target likely plural @cursor_stack[-2].replace(cursor, target) when cursor.ref? # target = resolve_ref @cursor_stack[-2].replace(cursor, target) cursor.remove_attribute(REF_ATTR_NAME) else @cursor_stack[-2].remove(cursor) return end @cursor_stack.pop end |
#start_element(name) ⇒ Object
28 29 30 31 32 |
# File 'lib/re_dux.rb', line 28 def start_element(name) new_el = Duxml::Element.new(name, line, column) cursor << new_el unless cursor.nil? @cursor_stack << new_el end |
#text(str) ⇒ Object
38 39 40 |
# File 'lib/re_dux.rb', line 38 def text(str) cursor << str end |