Class: DidYouMean::KeyErrorChecker
- Inherits:
-
Object
- Object
- DidYouMean::KeyErrorChecker
- Defined in:
- lib/did_you_mean/spell_checkers/key_error_checker.rb
Instance Method Summary collapse
- #corrections ⇒ Object
-
#initialize(key_error) ⇒ KeyErrorChecker
constructor
A new instance of KeyErrorChecker.
Constructor Details
#initialize(key_error) ⇒ KeyErrorChecker
Returns a new instance of KeyErrorChecker.
5 6 7 8 |
# File 'lib/did_you_mean/spell_checkers/key_error_checker.rb', line 5 def initialize(key_error) @key = key_error.key @keys = key_error.receiver.keys end |
Instance Method Details
#corrections ⇒ Object
10 11 12 |
# File 'lib/did_you_mean/spell_checkers/key_error_checker.rb', line 10 def corrections @corrections ||= exact_matches.empty? ? SpellChecker.new(dictionary: @keys).correct(@key).map(&:inspect) : exact_matches end |