Class: TodoNext::Tree::Visitor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/todo_next/tree/visitor/base.rb

Direct Known Subclasses

ExampleNodesRemover, LeafMaker, RspecGenerator

Instance Method Summary collapse

Instance Method Details

#process_non_terminal_node(curr_node, level, parent) ⇒ Object

overwrite in the concrete visitor class



23
24
# File 'lib/todo_next/tree/visitor/base.rb', line 23

def process_non_terminal_node(curr_node, level, parent)
end

#process_terminal_node(curr_node, level, parent) ⇒ Object

overwrite in the concrete visitor class



19
20
# File 'lib/todo_next/tree/visitor/base.rb', line 19

def process_terminal_node(curr_node, level, parent)
end

#visit(curr_node, level, parent) ⇒ Object

nodoc#



4
5
6
7
8
9
10
# File 'lib/todo_next/tree/visitor/base.rb', line 4

def visit(curr_node, level, parent) #nodoc#
  if curr_node.terminal?
    process_terminal_node(curr_node, level, parent)
  else
    process_non_terminal_node(curr_node, level, parent)
  end
end

#visit_children_of(parent, parent_level) ⇒ Object



12
13
14
15
16
# File 'lib/todo_next/tree/visitor/base.rb', line 12

def visit_children_of(parent, parent_level)
  parent.children.each do |node|
    visit(node, 1+parent_level, parent)
  end
end