Class: Utils::Patterns::FuzzyPattern

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

Instance Attribute Summary

Attributes inherited from Pattern

#matcher

Instance Method Summary collapse

Methods inherited from Pattern

#method_missing

Constructor Details

#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

Dynamic Method Handling

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