class DumbDownViewer::TreeViewBuilder
Attributes
tree_table[R]
Public Instance Methods
add_current_node_row(node)
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 174 def add_current_node_row(node) row = new_table_row row[node.depth] = node @tree_table.push row end
determine_depth(tree)
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 150 def determine_depth(tree) # update of test necessary @tree_depth = 0 depth_checker = Visitor.new do |node, memo| @tree_depth = node.depth > @tree_depth ? node.depth : @tree_depth end tree.accept(depth_checker, 0) end
format(formatter=PlainTextFormat.new)
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 140 def format(formatter=PlainTextFormat.new) formatter.format_table(@tree_table) end
new_table_row()
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 158 def new_table_row Array.new(@tree_depth + 1) end
setup(tree)
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 144 def setup(tree) @tree_table = [] determine_depth(tree) tree.accept(self, nil) end
visit_dir_node(node, memo)
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 162 def visit_dir_node(node, memo) add_current_node_row(node) [node.files, node.directories].each do |nodes| nodes.sort_by {|n| n.name }.each {|n| n.accept(self, memo) } end end
visit_file_node(node, memo)
click to toggle source
# File lib/dumb_down_viewer/tree_view_builder.rb, line 170 def visit_file_node(node, memo) add_current_node_row(node) end