Class: DirProcessor
- Inherits:
-
Object
- Object
- DirProcessor
- Defined in:
- lib/treevisitor/dir_processor.rb
Instance Method Summary collapse
- #add_processor(re, &action) ⇒ Object
-
#initialize(&action) ⇒ DirProcessor
constructor
A new instance of DirProcessor.
- #process(dirname) ⇒ Object
Constructor Details
#initialize(&action) ⇒ DirProcessor
Returns a new instance of DirProcessor.
5 6 7 8 |
# File 'lib/treevisitor/dir_processor.rb', line 5 def initialize( &action ) @processors = {} @default_processor = action end |
Instance Method Details
#add_processor(re, &action) ⇒ Object
10 11 12 |
# File 'lib/treevisitor/dir_processor.rb', line 10 def add_processor( re, &action ) @processors[ re ] = action end |
#process(dirname) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/treevisitor/dir_processor.rb', line 14 def process( dirname ) @dirname = dirname old_dirname = Dir.pwd Dir.chdir( @dirname ) Dir["**/*"].each { |f| pn = Pathname.new( f ). # puts "#{self.class.name}#loadfromdir #{f}" next if pn.directory? process_file( pn ) } Dir.chdir( old_dirname ) self end |