Method: Utils::Patterns::FuzzyPattern#initialize

Defined in:
lib/utils/patterns.rb

#initialize(opts = {}) ⇒ FuzzyPattern

Returns a new instance of FuzzyPattern.



22
23
24
25
26
27
28
29
30
# File 'lib/utils/patterns.rb', line 22

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