[DOC] expanded patterns in examples of File.fnmatch [ci skip]

This commit is contained in:
Nobuyoshi Nakada 2020-10-27 00:52:43 +09:00
parent 1467328edc
commit 9692aeedf1
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

22
dir.rb
View file

@ -285,25 +285,19 @@ class << File
# File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default. # File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true # period by default.
# File.fnmatch('.*', '.profile') #=> true # File.fnmatch('.*', '.profile') #=> true
# #
# rbfiles = '**/*.rb' # File.fnmatch('**/*.rb', 'main.rb') #=> false
# File.fnmatch(rbfiles, 'main.rb') #=> false # File.fnmatch('**/*.rb', './main.rb') #=> false
# File.fnmatch(rbfiles, './main.rb') #=> false # File.fnmatch('**/*.rb', 'lib/song.rb') #=> true
# File.fnmatch(rbfiles, 'lib/song.rb') #=> true
# File.fnmatch('**.rb', 'main.rb') #=> true # File.fnmatch('**.rb', 'main.rb') #=> true
# File.fnmatch('**.rb', './main.rb') #=> false # File.fnmatch('**.rb', './main.rb') #=> false
# File.fnmatch('**.rb', 'lib/song.rb') #=> true # File.fnmatch('**.rb', 'lib/song.rb') #=> true
# File.fnmatch('*', 'dave/.profile') #=> true # File.fnmatch('*', 'dave/.profile') #=> true
# #
# pattern = '*/*' # File.fnmatch('**/foo', 'a/b/c/foo', File::FNM_PATHNAME) #=> true
# File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME) #=> false # File.fnmatch('**/foo', '/a/b/c/foo', File::FNM_PATHNAME) #=> true
# File.fnmatch(pattern, 'dave/.profile', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true # File.fnmatch('**/foo', 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
# # File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
# pattern = '**/foo' # File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
# File.fnmatch(pattern, 'a/b/c/foo', File::FNM_PATHNAME) #=> true
# File.fnmatch(pattern, '/a/b/c/foo', File::FNM_PATHNAME) #=> true
# File.fnmatch(pattern, 'c:/a/b/c/foo', File::FNM_PATHNAME) #=> true
# File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
# File.fnmatch(pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
def fnmatch(pattern, path, flags = nil) def fnmatch(pattern, path, flags = nil)
end end
alias fnmatch? fnmatch alias fnmatch? fnmatch