123456789_123456789_123456789_123456789_123456789_

Class: DidYouMean::VariableNameChecker

Relationships & Source Files
Inherits: Object
Defined in: lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(exception) ⇒ VariableNameChecker

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 68

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

Instance Attribute Details

#cvar_names (readonly)

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 7

attr_reader :name, :method_names, :lvar_names, :ivar_names, :cvar_names

#ivar_names (readonly)

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 7

attr_reader :name, :method_names, :lvar_names, :ivar_names, :cvar_names

#lvar_names (readonly)

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 7

attr_reader :name, :method_names, :lvar_names, :ivar_names, :cvar_names

#method_names (readonly)

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 7

attr_reader :name, :method_names, :lvar_names, :ivar_names, :cvar_names

#name (readonly)

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 7

attr_reader :name, :method_names, :lvar_names, :ivar_names, :cvar_names

Instance Method Details

#corrections

[ GitHub ]

  
# File 'lib/did_you_mean/spell_checkers/name_error_checkers/variable_name_checker.rb', line 79

def corrections
  @corrections ||= SpellChecker
                 .new(dictionary: (RB_RESERVED_WORDS + lvar_names + method_names + ivar_names + cvar_names))
                 .correct(name) - NAMES_TO_EXCLUDE[@name]
end