class Wilderpeople::Matcher
Attributes
levenshtein_threshold[W]
a[R]
b[R]
dates[R]
Public Class Methods
by(method, a, b)
click to toggle source
Another way to use matcher is:
Matcher.by :exact, a, b
# File lib/wilderpeople/matcher.rb, line 28 def by(method, a, b) raise "Method must be defined" unless method new(a, b).send(method) end
levenshtein_threshold()
click to toggle source
# File lib/wilderpeople/matcher.rb, line 10 def levenshtein_threshold @levenshtein_threshold ||= 0.3 end
method_missing(method, *args, &block)
click to toggle source
Using `method_missing` so that instead of having to do:
Matcher.new(a, b).exact
We can do
Matcher.exact(a, b)
Calls superclass method
# File lib/wilderpeople/matcher.rb, line 18 def method_missing(method, *args, &block) if protected_instance_methods.include?(method) by(method, args[0], args[1]) else super end end
new(a, b)
click to toggle source
Passing arguments into initialize so that prep can be done just once and before main test. Also means that I don't have to worry about the result of one match poluting the next match
# File lib/wilderpeople/matcher.rb, line 40 def initialize(a, b) @a, @b = a.clone, b.clone prep end