Sha256: fdd1841e77dd69c7cd4051a0b091ad1741e7100252810d1373ba6456dfbc6f34
Contents?: true
Size: 546 Bytes
Versions: 2
Compression:
Stored size: 546 Bytes
Contents
require "text" module DidYouMean class MethodMatcher def initialize(method_collection, target_method) @method_collection = method_collection.uniq @target_method = target_method end def similar_methods @similar_methods ||= method_collection.select do |method| ::Text::Levenshtein.distance(method.to_s, target_method.to_s) <= sensitiveness end end private attr_reader :method_collection, :target_method def sensitiveness (target_method.size * 0.3).ceil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
did_you_mean-0.5.0 | lib/did_you_mean/method_finder.rb |
did_you_mean-0.4.0 | lib/did_you_mean/method_finder.rb |