Class: Jinx::Visitor::VisitorEnumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/jinx/helpers/visitor.rb

Instance Method Summary collapse

Methods included from Enumerable

#enumerate, #pp_s, #pretty_print, #pretty_print_cycle, #qp, #to_enum, #transitive_closure

Constructor Details

#initialize(visitor, node) ⇒ VisitorEnumerator

Returns a new instance of VisitorEnumerator.



296
297
298
299
# File 'lib/jinx/helpers/visitor.rb', line 296

def initialize(visitor, node)
  @visitor = visitor
  @root = node
end

Instance Method Details

#each {|node| ... } ⇒ Object

Yields:

  • (node)

    operates on the visited node

Yield Parameters:

  • node

    the visited node



303
304
305
# File 'lib/jinx/helpers/visitor.rb', line 303

def each
  @visitor.visit(@root) { |node| yield(node) }
end