Module: RGlob
- Defined in:
- lib/rglob.rb
Overview
Glob-syntax pattern matching library
Example:
g = RGlob::Glob.new('a/b*.rb')
g.match('a/b.rb') # returns true
g.match('a/c.rb') # returns false
The patterns hold the exact same meaning as in Dir.glob, but this library does not rely upon the filesystem. Glob objects have the exact same interface as Regexp.
Defined Under Namespace
Classes: Glob
Class Method Summary collapse
Class Method Details
.pattern_to_regexp(pattern) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/rglob.rb', line 91 def self.pattern_to_regexp(pattern) s = Regexp.escape(pattern) PatternReplacements.each do |from, to| s.gsub!(from, to) end return Regexp.new("^#{s}$") end |