Sha256: edf456be997d63ea6c9353b3e0e10355106b1b7a951391b79e03e6bc96d36113
Contents?: true
Size: 908 Bytes
Versions: 1
Compression:
Stored size: 908 Bytes
Contents
require 'treevisitor/tree_node' require 'treevisitor/dir_tree_walker' require 'treevisitor/tree_node_visitor' # # Buils a TreeNode from a filesystem directory # It similar to CloneTreeNodeVisitor # class BuildDirTreeVisitor < TreeNodeVisitor attr_reader :root attr_reader :nr_directories attr_reader :nr_files def initialize super @root = nil @stack = [] @nr_directories = 0 @nr_files = 0 end def enter_tree_node( pathname ) if @stack.empty? treeNode = TreeNode.new( File.basename( pathname ) ) @root = treeNode else treeNode = TreeNode.new( File.basename( pathname ), @stack.last ) end @nr_directories += 1 @stack.push( treeNode ) end def exit_tree_node( pathname ) @stack.pop end def visit_leaf_node( pathname ) @nr_files += 1 leafNode = LeafNode.new( File.basename(pathname), @stack.last ) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gf-treevisitor-0.0.10 | lib/treevisitor/visitors/build_dir_tree_visitor.rb |