Class: Utils::Patterns::FuzzyPattern

Inherits:
Pattern show all
Defined in:
lib/utils/patterns.rb

Instance Method Summary collapse

Methods inherited from Pattern

#method_missing

Constructor Details

#initialize(opts = {}) ⇒ FuzzyPattern

Returns a new instance of FuzzyPattern.



18
19
20
21
22
23
24
# File 'lib/utils/patterns.rb', line 18

def initialize(opts ={})
  super
  r        = @pattern.split(//).map { |x| "(#{Regexp.quote(x)})" } * '.*?'
  @matcher = Regexp.new(
    "\\A(?:.*/.*?#{r}|.*#{r})",
    @icase ? Regexp::IGNORECASE : 0)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Utils::Patterns::Pattern