From: josh.guthrie+ruby@... Date: 2015-06-24T15:44:13+00:00 Subject: [ruby-dev:49138] [Ruby trunk - Feature #11302] Dir.entries and Dir.foreach without [".", ".."] Issue #11302 has been updated by Arnaud Rouyer. Nobuyoshi Nakada wrote: > Candidates for the methods or options? > > I prefer a same option for both methods, but no concrete idea. Dir.foreach and Dir.entries both support a second hash argument for options: as of 2.2.2, the docs only mention the :encoding key in the options hash. Basing myself on the GNU ls util, I propose supporting an :ignore key in the optional hash argument. We could have an API similar to this: ~~~ $ ls -a . .. .hidden_file directory file.bin $ irb irb:001> Dir.entries('.') => [".", "..", ".hidden_file", "directory", "file.bin"] irb:002> Dir.entries('.', ignore: :almost_all) # almost_all option name taken from GNU ls option name => [".hidden_file", "directory", "file.bin"] # http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/ls.c#n4784 irb:003> Dir.entries('.', ignore: :directories) => [".hidden_file", "file.bin"] irb:004> Dir.entries('.', ignore: :hidden) => ["directory", "file.bin"] # Fancy proposal irb:005> Dir.entries('.', ignore: /o/) => [".", "..", ".hidden_file", "file.bin"] ~~~ ---------------------------------------- Feature #11302: Dir.entries and Dir.foreach without [".", ".."] https://bugs.ruby-lang.org/issues/11302#change-53113 * Author: Yui NARUSE * Status: Assigned * Priority: Normal * Assignee: Yukihiro Matsumoto ---------------------------------------- Dir.entries returns an array of its content with "." and "..". But as far as I met, almost all cases don't need them. How about adding such new method or options? -- https://bugs.ruby-lang.org/