Class: DidYouMean::MethodNameChecker
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/did_you_mean/spell_checkers/method_name_checker.rb | 
Constant Summary
- 
    NAMES_TO_EXCLUDE =
    
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 7{ NilClass => nil.methods } - 
    RB_RESERVED_WORDS =
    # File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 20
RB_RESERVED_WORDSis the list of reserved words in Ruby that take an argument. Unlike VariableNameChecker::RB_RESERVED_WORDS, these reserved words require an argument, and aNoMethodErroris raised due to the presence of the argument.The
MethodNameCheckerwill use this list to suggest a reversed word if aNoMethodErroris raised and found closest matches.Also see VariableNameChecker::RB_RESERVED_WORDS.
%i( alias case def defined? elsif end ensure for rescue super undef unless until when while yield ) 
Class Method Summary
- .new(exception) ⇒ MethodNameChecker constructor
 
Instance Attribute Summary
- #method_name readonly
 - #receiver readonly
 
Instance Method Summary
Constructor Details
    .new(exception)  ⇒ MethodNameChecker 
  
# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 39
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 (readonly)
[ GitHub ]# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 5
attr_reader :method_name, :receiver
#receiver (readonly)
[ GitHub ]# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 5
attr_reader :method_name, :receiver
Instance Method Details
#corrections
[ GitHub ]# File 'lib/did_you_mean/spell_checkers/method_name_checker.rb', line 45
def corrections @corrections ||= SpellChecker.new(dictionary: RB_RESERVED_WORDS + method_names).correct(method_name) - NAMES_TO_EXCLUDE[@receiver.class] end