Class: Glimmer::XML::DepthFirstSearchIterator

Inherits:
Object
  • Object
show all
Defined in:
lib/glimmer/xml/depth_first_search_iterator.rb

Instance Method Summary collapse

Constructor Details

#initialize(node, node_visitor) ⇒ DepthFirstSearchIterator

Returns a new instance of DepthFirstSearchIterator.



27
28
29
30
# File 'lib/glimmer/xml/depth_first_search_iterator.rb', line 27

def initialize(node, node_visitor)
  @node = node
  @node_visitor = node_visitor
end

Instance Method Details

#iterateObject



32
33
34
# File 'lib/glimmer/xml/depth_first_search_iterator.rb', line 32

def iterate
  process(@node)
end

#process(node) ⇒ Object



36
37
38
39
40
# File 'lib/glimmer/xml/depth_first_search_iterator.rb', line 36

def process(node)
  @node_visitor.process_before_children(node)
  node.children.each { |child| process(child) } if node.is_a?(Node)
  @node_visitor.process_after_children(node)
end