From: nobu.nokada@... Date: 2002-03-16T15:27:49+09:00 Subject: Re: Some potential RCRs Hi, At Sat, 16 Mar 2002 06:16:40 +0900, ; wrote: > > > >As Guy posted, Dir[dirname + '*'] will do the same, except it includes the > >directory name in each entry. > > > >Maybe these sort of functions would be good additions to ftools.rb? > > > > - - I did some more thinking about this and it seems to me that a > good name would be Dir::slice. Somewhat similar in concept to > Array::slice. Or perhaps Dir::collect. Hmm, does Dir implement > Emunerable? # Array doesn't have class method `slice'. Dir includes Enumerable not but extend it. So you can use Dir#grep, Dir#collect and so on. > Here's a simple minded implementation. > > # This implements the method > # Dir::slice(dirname,test, proc ) > # It returns an array of names that pass the test and > # if proc is available runs that on them and returns > # that resulting array. It looks like Dir.entries except for the test, but the name `slice' may cause confusion? It's not close to Array#slice. -- Nobu Nakada