class TreePrintVisitor
Constants
- ALL_LEVELS
Public Class Methods
new(dataSource, io, level=ALL_LEVELS)
click to toggle source
# File lib/visitor/tree_print_visitor.rb, line 4 def initialize(dataSource, io, level=ALL_LEVELS) @indentation = 0 @dataSource = dataSource @io = io @level = level end
Public Instance Methods
nodeToStr(node)
click to toggle source
# File lib/visitor/tree_print_visitor.rb, line 11 def nodeToStr(node) if (node.isRoot) then "ROOT" else "#{@dataSource.toString(node.incomingEdgeStartOffset, node.incomingEdgeEndOffset)}" end end
postVisit(node)
click to toggle source
# File lib/visitor/tree_print_visitor.rb, line 29 def postVisit(node) @indentation -= 1 end
preVisit(node)
click to toggle source
# File lib/visitor/tree_print_visitor.rb, line 19 def preVisit(node) @io.print "#{" "*@indentation}#{self.nodeToStr(node)}\n" if (@level == ALL_LEVELS) || (@indentation < @level) then @indentation += 1 return true else return false end end