Class: ErrorToCommunicate::Heuristic::NoMethodError
Instance Attribute Summary
#einfo, #project
Class Method Summary
collapse
Instance Method Summary
collapse
#backtrace, #classname, #explanation, #initialize, #message, #semantic_backtrace, #semantic_summary
Class Method Details
.for?(einfo) ⇒ Boolean
8
9
10
11
12
|
# File 'lib/error_to_communicate/heuristic/no_method_error.rb', line 8
def self.for?(einfo)
( einfo.classname == 'NoMethodError' ||
einfo.classname == 'NameError'
) && parse_undefined_name(einfo.message)
end
|
Instance Method Details
#semantic_explanation ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/error_to_communicate/heuristic/no_method_error.rb', line 30
def semantic_explanation
if misspelling?
"You called the method `#{undefined_method_name}' on `#{name_of_ivar}', which is nil\nPossible misspelling of `#{closest_name}'"
else
super
end
end
|
#semantic_info ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/error_to_communicate/heuristic/no_method_error.rb', line 18
def semantic_info
[:heuristic,
[:code, {
location: backtrace[0],
highlight: backtrace[0].label,
context: -5..5,
message: "#{undefined_method_name} is undefined",
emphasis: :code,
}]
]
end
|
#undefined_method_name ⇒ Object
14
15
16
|
# File 'lib/error_to_communicate/heuristic/no_method_error.rb', line 14
def undefined_method_name
self.class.parse_undefined_name message
end
|