From: David Alan Black Date: 2002-01-12T00:19:15+09:00 Subject: Re: Dir.entries have no home Hi -- On Fri, 11 Jan 2002, Ron Jeffries wrote: > Chet and I were writing a little code manager yesterday and we wrote > this code: > > def filesUnderManagement > names = (Dir.entries(@directoryName). > select { | each | ! (/.bak/ =~ each) }).sort > names.reject { |each| FileTest.directory?(each) } > end > > The idea was to have all the file names that weren't named *.bak > (which is a thing TextPad does) and weren't directories. It would be mildly out of character for me to post what turns out to be the best way of doing something like this, but here's at least one way that I think achieves what you want, using Dir.[] (aka Dir.glob): def filesUnderManagement Dir["#{@dir_name}/*"].reject do |f| test(?d,f) || /\.bak$/.match(f) end .sort end (Is this too race-condition-infested? Is there a way around that?) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav