# class DidYouMean::VariableNameChecker

### Constants

NAMES_TO_EXCLUDE
RB_PREDEFINED_OBJECTS

### Attributes

cvar_names[R]
ivar_names[R]
lvar_names[R]
method_names[R]
name[R]

### Public Class Methods

new(exception) click to toggle source

    # File lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb, line 13
    def initialize(exception)
      @name       = exception.name.to_s.tr("@", "")
      @lvar_names = exception.respond_to?(:local_variables) ? exception.local_variables : []
      receiver    = exception.receiver

      @method_names = receiver.methods + receiver.private_methods
      @ivar_names   = receiver.instance_variables
      @cvar_names   = receiver.class.class_variables
      @cvar_names  += receiver.class_variables if receiver.kind_of?(Module)
    end

### Public Instance Methods

corrections() click to toggle source

    # File lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb, line 24
    def corrections
      @corrections ||= SpellChecker
                     .new(dictionary: (RB_PREDEFINED_OBJECTS + lvar_names + method_names + ivar_names + cvar_names))
                     .correct(name) - NAMES_TO_EXCLUDE[@name]
    end