Module: MyUtilities::MyDir::MyDirMethods
- Defined in:
- lib/my_utilities.rb
Instance Method Summary collapse
Instance Method Details
#parent_dir_match(rx, dir = ".") ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/my_utilities.rb', line 94 def parent_dir_match(rx, dir=".") # nil if this isn't a directory we're starting from return nil if !Dir.exists? dir find_files = Dir.entries(dir).select { |x| rx.match x and File.file? File.join(dir, x) } return dir unless find_files.empty? # Don't recurse if the dir's parent is the dir return parent_dir_match(rx, File.join(dir, "..")) if(File.(dir) != '/') nil end |