Class: ErrorToCommunicate::Heuristic
- Inherits:
-
Object
- Object
- ErrorToCommunicate::Heuristic
- Defined in:
- lib/error_to_communicate/heuristic.rb,
lib/error_to_communicate/heuristic/exception.rb,
lib/error_to_communicate/heuristic/load_error.rb,
lib/error_to_communicate/heuristic/syntax_error.rb,
lib/error_to_communicate/heuristic/no_method_error.rb,
lib/error_to_communicate/heuristic/wrong_number_of_arguments.rb
Direct Known Subclasses
Exception, LoadError, NoMethodError, RSpecFailure, SyntaxError, WrongNumberOfArguments
Defined Under Namespace
Classes: Exception, LoadError, NoMethodError, RSpecFailure, SyntaxError, WrongNumberOfArguments
Instance Attribute Summary collapse
-
#einfo ⇒ Object
Returns the value of attribute einfo.
-
#project ⇒ Object
Returns the value of attribute project.
Class Method Summary collapse
Instance Method Summary collapse
- #backtrace ⇒ Object
- #classname ⇒ Object
-
#explanation ⇒ Object
Is this really a thing that should be in toplevel heuristic?.
-
#initialize(attributes) ⇒ Heuristic
constructor
A new instance of Heuristic.
- #message ⇒ Object
- #semantic_backtrace ⇒ Object
- #semantic_explanation ⇒ Object
- #semantic_info ⇒ Object
-
#semantic_summary ⇒ Object
The responsibility of structuring should move to the heuristic Then, the classname and explanation can be separated from the summary and columns.
Constructor Details
#initialize(attributes) ⇒ Heuristic
Returns a new instance of Heuristic.
9 10 11 12 |
# File 'lib/error_to_communicate/heuristic.rb', line 9 def initialize(attributes) self.einfo = attributes.fetch :einfo self.project = attributes.fetch :project end |
Instance Attribute Details
#einfo ⇒ Object
Returns the value of attribute einfo.
7 8 9 |
# File 'lib/error_to_communicate/heuristic.rb', line 7 def einfo @einfo end |
#project ⇒ Object
Returns the value of attribute project.
7 8 9 |
# File 'lib/error_to_communicate/heuristic.rb', line 7 def project @project end |
Class Method Details
.for?(einfo) ⇒ Boolean
3 4 5 |
# File 'lib/error_to_communicate/heuristic.rb', line 3 def self.for?(einfo) raise NotImplementedError, "#{self} needs to implement .for? (subclass responsibility)" end |
Instance Method Details
#backtrace ⇒ Object
18 19 20 |
# File 'lib/error_to_communicate/heuristic.rb', line 18 def backtrace einfo.backtrace end |
#classname ⇒ Object
14 15 16 |
# File 'lib/error_to_communicate/heuristic.rb', line 14 def classname einfo.classname end |
#explanation ⇒ Object
Is this really a thing that should be in toplevel heuristic?
27 28 29 |
# File 'lib/error_to_communicate/heuristic.rb', line 27 def explanation end |
#message ⇒ Object
22 23 24 |
# File 'lib/error_to_communicate/heuristic.rb', line 22 def einfo. end |
#semantic_backtrace ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/error_to_communicate/heuristic.rb', line 51 def semantic_backtrace [:backtrace, backtrace.map do |location| [:code, { location: location, highlight: (location.pred && location.pred.label), context: 0..0, emphasis: :path, mark: false, }] end ] end |
#semantic_explanation ⇒ Object
31 32 33 |
# File 'lib/error_to_communicate/heuristic.rb', line 31 def semantic_explanation explanation end |
#semantic_info ⇒ Object
47 48 49 |
# File 'lib/error_to_communicate/heuristic.rb', line 47 def semantic_info [:null] end |
#semantic_summary ⇒ Object
The responsibility of structuring should move to the heuristic Then, the classname and explanation can be separated from the summary and columns. Which allows us to compose heuristics by composing their columnal information, and placing it in our own structural format
40 41 42 43 44 45 |
# File 'lib/error_to_communicate/heuristic.rb', line 40 def semantic_summary [:summary, [ [:columns, [:classname, classname], [:explanation, semantic_explanation]]]] end |