Ruby/File Directory/Dir.reject
Материал из Wiki.crossplatform.ru
(Различия между версиями)
ViGOur (Обсуждение | вклад) м (1 версия: Импорт выборки материалов по Ruby) |
Текущая версия на 17:57, 13 сентября 2010
Get all contents other than ".", "..", and hidden files.
d = Dir.open("mydir") d.reject { |f| f[0] == "." } d.close
Get the names of all files in the directory.
d = Dir.open("mydir") d.reject { |f| f[0] == "." } d.rewind d.reject { |f| !File.file? File.join(d.path, f) } d.close