Sha256: 97c7d3be8b635ed73be3a432e0648647b49ff1a033091798ecbfe9870100ab57
Contents?: true
Size: 744 Bytes
Versions: 1
Compression:
Stored size: 744 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} with no subdir" end end end dtw = TreeRb::DirTreeWalker.new( File.join('..', '..') ) dtw.ignore /^\./ dtw.visit_file=false dtw.run( DirWithoutSubDir.new )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tree.rb-0.3.13 | examples/ruby_examples/find_directory_without_subdirectory.rb |