On Thu, 12 May 2005 13:33:25 +0200, Robert Klemme wrote: > <snip> > Even more generic: > > module Find > def self.find_cond(dir, cond) > find(dir){|f| yield f if cond === f} > end > end > > Find::find_cond ".", /\.jsp$/ do |f| > puts f > end > > # and including the file type test > proper_test = Object.new > def proper_test.===(f) /\.jsp$/ =~ f and File.file? f end > > Find::find_cond ".", proper_test do |f| > puts f > end > For this kind of thing I find the enumerator module very useful: require 'find' require 'enumerator' Find.to_enum(:find, ".").grep(/\.jsp$/) => #array of files that end with .jsp # or (to exclude directories): Find.to_enum(:find, ".").select do |f| /\.jsp$/ =~ f && File.file? f end Cheers, KB