Class: ErrorToCommunicate::Heuristic::WrongNumberOfArguments
- Inherits:
-
ErrorToCommunicate::Heuristic
- Object
- ErrorToCommunicate::Heuristic
- ErrorToCommunicate::Heuristic::WrongNumberOfArguments
- Defined in:
- lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb
Instance Attribute Summary collapse
-
#explanation ⇒ Object
Returns the value of attribute explanation.
-
#num_expected ⇒ Object
Returns the value of attribute num_expected.
-
#num_received ⇒ Object
Returns the value of attribute num_received.
Attributes inherited from ErrorToCommunicate::Heuristic
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ WrongNumberOfArguments
constructor
A new instance of WrongNumberOfArguments.
- #semantic_explanation ⇒ Object
- #semantic_info ⇒ Object
Methods inherited from ErrorToCommunicate::Heuristic
#backtrace, #classname, #message, #semantic_backtrace, #semantic_summary
Constructor Details
#initialize ⇒ WrongNumberOfArguments
Returns a new instance of WrongNumberOfArguments.
12 13 14 15 16 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 12 def initialize(*) super self.num_received, self.num_expected = self.class.extract_from() self.explanation = 'Wrong number of arguments' end |
Instance Attribute Details
#explanation ⇒ Object
Returns the value of attribute explanation.
10 11 12 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 10 def explanation @explanation end |
#num_expected ⇒ Object
Returns the value of attribute num_expected.
10 11 12 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 10 def num_expected @num_expected end |
#num_received ⇒ Object
Returns the value of attribute num_received.
10 11 12 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 10 def num_received @num_received end |
Class Method Details
.for?(einfo) ⇒ Boolean
6 7 8 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 6 def self.for?(einfo) extract_from einfo. end |
Instance Method Details
#semantic_explanation ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 18 def semantic_explanation [ :message, [ [:explanation, explanation], [:context, ' (expected '], [:details, num_expected], [:context, ', sent '], [:details, num_received], [:context, ')'], ] ] end |
#semantic_info ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb', line 30 def semantic_info if backtrace.length == 0 [:context, "Couldn\'t find anything interesting ¯\_(ツ)_/¯\n"] elsif backtrace.length == 1 [:heuristic, [:code, { location: backtrace[0], highlight: backtrace[0].label, context: (-5..5), emphasis: :code, }]] else [:heuristic, [ [:code, { location: backtrace[0], highlight: backtrace[0].label, context: 0..5, message: "EXPECTED #{num_expected}", emphasis: :code, }], [:code, { location: backtrace[1], highlight: backtrace[0].label, context: -5..5, message: "SENT #{num_received}", emphasis: :code, }], ]] end end |