require 'find' module Find def match(*paths) matched = [] find(*paths) { |path| matched << path if yield path } return matched end module_function :match end p Find.match('./') { |p| File.split(p)[1] == 'README' }