Prev: 1.9.2 RC2 Uses 1.9.1 for various directories
Next: Installing mysql gem on Win7 x64 for MySQL 5.1.x
From: Kyle Barbour on 2 Aug 2010 16:09 Thanks for all the responses! I feel so thoroughly helped :) On Aug 2, 7:01 am, Marvin Gülker <sutn...(a)gmx.net> wrote: > By calling Dir.foreach("dir") you'll get "my_file" and "my_second_file". > Your File.file? statement then checks for the presence of the filenames > in the current working directory -- where they don't reside. Solution: > Append "dir" to the filename. Martin - thanks for the diagnosis, that makes perfect sense. Awesome. That works very well and solves my problem! On Aug 2, 6:05 am, Brian Candler <b.cand...(a)pobox.com> wrote: > As an alternative, Dir["etc/*"] builds an Array directly. So you could > have: > > def get_files(dir) > Dir["#{dir}/*"].select { |x| File.file?(x) } > end Interesting, thanks! Is there any reason to prefer either this solution or the one Martin gave in the above post? Also: everyone, thanks for the newbie friendliness and for the general advice (snake_case, negative logic, etc.). Thoroughly appreciated. Kyle
|
Pages: 1 Prev: 1.9.2 RC2 Uses 1.9.1 for various directories Next: Installing mysql gem on Win7 x64 for MySQL 5.1.x |