Exception: Mentor::NoMethodDidYouMeanNumericLiteralError

Inherits:
MentorNoMethodError show all
Defined in:
lib/errors/no_method_did_you_mean_numeric_literal.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Colorize

#colorize, #colorize_section

Methods included from OutputHelper

#a_an, #and_sentence, #culprit_line, #home_to_tilde, #indent_lines, #lines_from_file, #or_sentence, #pluralize, #pluralize_words, #terminal_width, #valid_var_name

Methods inherited from MentorError

error_classes, find, #output

Class Method Details

.can_handle?Boolean

Returns:

  • (Boolean)


5
6
7
8
9
10
11
# File 'lib/errors/no_method_did_you_mean_numeric_literal.rb', line 5

def self.can_handle?
  super &&
    Mentor.tp.raised_exception.respond_to?(:corrections) &&
    Mentor.tp.raised_exception.corrections.any? &&
    var_for_method.empty? &&
    [Integer, Float].include?(Mentor.tp.raised_exception.receiver.class)
end

Instance Method Details

#sectionsObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/errors/no_method_did_you_mean_numeric_literal.rb', line 13

def sections
  [
    Header.new,
    RubyErrorComplete.new,
    RelativePath.new,
    LinesOfCode.new,
    ErrorClassSpecificHelp.new(error_class_specific_help),
    Suggestion.new("Try changing the method #{method_name} to #{did_you_mean_word} on your #{literal_class}.")
  ]
end