Method: Jinx::Visitor#initialize
- Defined in:
- lib/jinx/helpers/visitor.rb
#initialize(opts = nil) {|parent| ... } ⇒ Visitor
Creates a new Visitor which traverses the child objects returned by the navigator block. The navigator block takes a parent node argument and returns an enumerator on the children to visit. The options argument is described in Options.get.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/jinx/helpers/visitor.rb', line 71 def initialize(opts=nil, &navigator) raise ArgumentError.new('Visitor cannot be created without a navigator block') unless block_given? @navigator = navigator = Options.to_hash(opts) @depth_first_flag = [:depth_first] @prune_cycle_flag = [:prune_cycle] @lineage = [] @visited = {} @verbose = Options.get(:verbose, opts, false) @exclude = Set.new end |