Sha256: 40d4774e199a151ec40003a274bada6df6fa8dfbdea452fff0599a955f574bb7
Contents?: true
Size: 737 Bytes
Versions: 1
Compression:
Stored size: 737 Bytes
Contents
# -*- coding: utf-8 -*- require 'ostruct' cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib" ) ) $:.unshift(cwd) unless $:.include?(cwd) require 'treevisitor' # # Find directories without subdirectories # class DirWithoutSubDir < TreeVisitor::BasicTreeNodeVisitor def initialize super @stack = [] @nr = 0 end def enter_tree_node( pathname ) @nr += 1 info = OpenStruct.new(:nr => @nr, :pathname => pathname) @stack.push( info ) end def exit_tree_node( pathname ) info = @stack.pop if info.nr == @nr puts "leaf: #{pathname}" end end end dtw = TreeVisitor::DirTreeWalker.new( ".." ) dtw.ignore /^\./ dtw.visit_file=false dtw.run( DirWithoutSubDir.new )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
treevisitor-0.1.6 | examples/directory_walker/directory_without_subdirectory.rb |