-------------------------------------------------------------- Dir::glob
Dir.glob( pattern, [flags] ) => array
Dir.glob( pattern, [flags] ) {| filename | block } => nil
------------------------------------------------------------------------
Returns the filenames found by expanding _pattern_ which is an
Array of the patterns or the pattern +String+, either as an
_array_ or as parameters to the block. Note that this pattern is
not a regexp (it's closer to a shell glob). See +File::fnmatch+ for
the meaning of the _flags_ parameter. Note that case sensitivity
depends on your system (so +File::FNM_CASEFOLD+ is ignored)
<code>*</code>: Matches any file. Can be restricted by other
values in the glob. +*+ will match all files;
+c*+ will match all files beginning with +c+;
+*c+ will match all files ending with +c+; and
*+c+* will match all files that have c in
them (including at the beginning or end).
Equivalent to +/ .* /x+ in regexp.
<code>**</code>: Matches directories recursively.
<code>?</code>: Matches any one character. Equivalent to
+/.{1}/+ in regexp.
<code>[set]</code>: Matches any one character in +set+. Behaves
exactly like character sets in Regexp,
including set negation (+[^a-z]+).
<code>{p,q}</code>: Matches either literal p or literal +q+.
Matching literals may be more than one
character in length. More than two literals may
be specified. Equivalent to pattern alternation
in regexp.
<code>\</code>: Escapes the next metacharacter.
Dir["config.?"] #=> ["config.h"]
Dir.glob("config.?") #=> ["config.h"]
Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
Dir.glob("*.[^r]*") #=> ["config.h"]
Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
Dir.glob("*") #=> ["config.h", "main.rb"]
Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
rbfiles = File.join("**", "*.rb")
Dir.glob(rbfiles) #=> ["main.rb",
"lib/song.rb",
"lib/song/karaoke.rb"]
libdirs = File.join("**", "lib")
Dir.glob(libdirs) #=> ["lib"]
librbfiles = File.join("**", "lib", "**", "*.rb")
Dir.glob(librbfiles) #=> ["lib/song.rb",
"lib/song/karaoke.rb"]
librbfiles = File.join("**", "lib", "*.rb")
Dir.glob(librbfiles) #=> ["lib/song.rb"]