module MyUtilities::MyDir::MyDirMethods
Public Instance Methods
parent_dir_match(rx, dir=".")
click to toggle source
# 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.expand_path(dir) != '/') nil end