Attributes
Read
No documentation available
Class Methods
lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb, line 9
def initialize(exception)
@class_name, @receiver, @original_message = exception.name, exception.receiver, exception.original_message
end
No documentation available
Instance Methods
lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb, line 20
def class_names
scopes.flat_map do |scope|
scope.constants.map do |c|
ClassName.new(c, scope == Object ? "" : "#{scope}::")
end
end
end
No documentation available
lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb, line 13
def corrections
@corrections ||= SpellChecker.new(dictionary: class_names)
.correct(class_name)
.map(&:full_name)
.reject {|qualified_name| @original_message.include?(qualified_name) }
end
No documentation available
#
lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/did_you_mean/spell_checkers/name_error_checkers/class_name_checker.rb, line 28
def scopes
@scopes ||= @receiver.to_s.split("::").inject([Object]) do |_scopes, scope|
_scopes << _scopes.last.const_get(scope)
end.uniq
end
No documentation available