class DidYouMean::MethodNameChecker

Attributes

method_name[R]
receiver[R]

Public Class Methods

new(exception) click to toggle source
# File lib/did_you_mean/spell_checkers/method_name_checker.rb, line 5
def initialize(exception)
  @method_name = exception.name
  @receiver    = exception.receiver
  @has_args    = !exception.args&.empty?
end

Public Instance Methods

corrections() click to toggle source
# File lib/did_you_mean/spell_checkers/method_name_checker.rb, line 11
def corrections
  @corrections ||= SpellChecker.new(dictionary: method_names).correct(method_name)
end
method_names() click to toggle source
# File lib/did_you_mean/spell_checkers/method_name_checker.rb, line 15
def method_names
  method_names = receiver.methods + receiver.singleton_methods
  method_names += receiver.private_methods if @has_args
  method_names.uniq!
  method_names
end