Class: Dir
- Defined in:
- lib/nano/dir/%3A%3Als_r.rb,
lib/nano/dir/%3A%3Arecurse.rb
Overview
– Credit due to George Moschovitis <[email protected]> ++
Class Method Summary collapse
-
.ls_r(path = '.', &block) ⇒ Object
(also: recurse)
Recursively scan a directory and pass each file to the given block.
Class Method Details
.ls_r(path = '.', &block) ⇒ Object Also known as: recurse
Recursively scan a directory and pass each file to the given block.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nano/dir/%3A%3Als_r.rb', line 7 def self.ls_r(path='.', &block) list = [] stoplist = ['.', '..'] Dir.foreach(path) do |f| next if stoplist.include?(f) filename = path + '/' + f list << filename block.call(filename) if block if FileTest.directory?(filename) and not FileTest.symlink?(filename) list.concat( Dir.recurse(filename, &block) ) end end list end |