Class: DidYouMean::MethodNameChecker
- Inherits:
-
Object
- Object
- DidYouMean::MethodNameChecker
- Defined in:
- lib/did_you_mean/spell_checkers/method_name_checker.rb
Constant Summary collapse
- NAMES_TO_EXCLUDE =
{ NilClass => nil.methods }
Instance Attribute Summary collapse
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
Instance Method Summary collapse
- #corrections ⇒ Object
-
#initialize(exception) ⇒ MethodNameChecker
constructor
A new instance of MethodNameChecker.
- #method_names ⇒ Object
Constructor Details
#initialize(exception) ⇒ MethodNameChecker
Returns a new instance of MethodNameChecker.
10 11 12 13 14 |
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 10 def initialize(exception) @method_name = exception.name @receiver = exception.receiver @private_call = exception.respond_to?(:private_call?) ? exception.private_call? : false end |
Instance Attribute Details
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
5 6 7 |
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 5 def method_name @method_name end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
5 6 7 |
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 5 def receiver @receiver end |
Instance Method Details
#corrections ⇒ Object
16 17 18 |
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 16 def corrections @corrections ||= SpellChecker.new(dictionary: method_names).correct(method_name) - NAMES_TO_EXCLUDE[@receiver.class] end |
#method_names ⇒ Object
20 21 22 23 24 25 |
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 20 def method_names method_names = receiver.methods + receiver.singleton_methods method_names += receiver.private_methods if @private_call method_names.uniq! method_names end |