From: Michael Witrant Date: 2002-01-24T05:56:18+09:00 Subject: Re: Minor thoughts on 'Find' module On Wed, 23 Jan 2002 15:45:06 +0900 matz@ruby-lang.org (Yukihiro Matsumoto) wrote: > In message "Minor thoughts on 'Find' module" > on 02/01/23, Garance A Drosihn writes: > > |I've seen some messages about ways to get ruby to do the depth-first > |trick, but I do not remember those as being options to 'Find', which > |seems to me to be the logical place to have the option. > > Could you propose the possible API of the "new Find"? What about Find.find(root = '.', *options)? Options could be symbols or hashes. Each symbol is converted to a hash like { :symbol => true }. Options are then flattened and converted to a unique hash. Some options could be compatible, some not. Possible options: :files_first :directories_first :depth_first :files_only :directories_only :match => regexp :follow_symlinks :max_depth => integer :without_root # this one would delete the provided root # from the returned/yielded file names ... And why not all those wonderfull options find(1) provides? Also, without block given, it should return an array of those files. Samples: Find.find('.', :follow_symlinks, :files_only, :match => /\.mp3$/i) { |file| MP3::Player.play file } Find.find('/tmp', :without_root, :directories_first, :max_depth => 3) { ... } I did not think about the implementation, though. Mike.