Sha256: 7472a4e0b885436b98bccc2b98d293d463c149b00859e2007495bab3385fb4f4
Contents?: true
Size: 730 Bytes
Versions: 2
Compression:
Stored size: 730 Bytes
Contents
# -*- coding: utf-8 -*- require 'ostruct' cwd = File.expand_path( File.join( File.dirname(__FILE__), "..", "..", "lib" ) ) $:.unshift(cwd) unless $:.include?(cwd) require 'tree_rb' # # Find directories without subdirectories # class DirWithoutSubDir < TreeRb::BasicTreeNodeVisitor def initialize super @stack = [] @nr = 0 end def enter_node( pathname ) @nr += 1 info = OpenStruct.new(:nr => @nr, :pathname => pathname) @stack.push( info ) end def exit_node( pathname ) info = @stack.pop if info.nr == @nr puts "leaf: #{pathname}" end end end dtw = TreeRb::DirTreeWalker.new( File.join("..", ".." )) dtw.ignore /^\./ dtw.visit_file=false dtw.run( DirWithoutSubDir.new )
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tree.rb-0.3.10 | examples/ruby_examples/find_directory_without_subdirectory.rb |
tree.rb-0.3.9 | examples/ruby_examples/find_directory_without_subdirectory.rb |