Class: XMLInstantiatorTest::PruneTestInstantiator
- Inherits:
-
RGen::Instantiator::NodebasedXMLInstantiator
- Object
- RGen::Instantiator::AbstractInstantiator
- RGen::Instantiator::NodebasedXMLInstantiator
- XMLInstantiatorTest::PruneTestInstantiator
- Defined in:
- lib/puppet/vendor/rgen/test/xml_instantiator_test.rb
Instance Attribute Summary collapse
-
#max_depth ⇒ Object
readonly
Returns the value of attribute max_depth.
Instance Method Summary collapse
- #calc_max_depth(node, offset) ⇒ Object
-
#initialize(env) ⇒ PruneTestInstantiator
constructor
A new instance of PruneTestInstantiator.
- #on_ascent(node) ⇒ Object
- #on_descent(node) ⇒ Object
Methods inherited from RGen::Instantiator::NodebasedXMLInstantiator
#end_element, #instantiate, #instantiate_file, #namespaces, #on_chardata, #parse, prune_level, set_prune_level, #start_element
Methods inherited from RGen::Instantiator::AbstractInstantiator
Constructor Details
#initialize(env) ⇒ PruneTestInstantiator
Returns a new instance of PruneTestInstantiator.
48 49 50 51 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test.rb', line 48 def initialize(env) super(env) @max_depth = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RGen::Instantiator::AbstractInstantiator
Instance Attribute Details
#max_depth ⇒ Object (readonly)
Returns the value of attribute max_depth.
44 45 46 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test.rb', line 44 def max_depth @max_depth end |
Instance Method Details
#calc_max_depth(node, offset) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test.rb', line 60 def calc_max_depth(node, offset) if node.children.nil? || node.children.size == 0 @max_depth = offset if offset > @max_depth else node.children.each do |c| calc_max_depth(c, offset+1) end end end |
#on_ascent(node) ⇒ Object
56 57 58 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test.rb', line 56 def on_ascent(node) calc_max_depth(node, 0) end |
#on_descent(node) ⇒ Object
53 54 |
# File 'lib/puppet/vendor/rgen/test/xml_instantiator_test.rb', line 53 def on_descent(node) end |