Class: WhyChain::Explainer
- Inherits:
-
Object
- Object
- WhyChain::Explainer
- Defined in:
- lib/why_chain/explainer.rb,
lib/why_chain/explainer/colorizer.rb,
lib/why_chain/explainer/compact_formatter.rb,
lib/why_chain/explainer/teaching_formatter.rb
Overview
Formats a human-friendly runtime dispatch explanation.
Defined Under Namespace
Classes: Colorizer, CompactFormatter, TeachingFormatter
Instance Method Summary collapse
-
#initialize(trace, method_name, style: :teaching, color: :auto, graph: true) ⇒ Explainer
constructor
A new instance of Explainer.
- #to_s ⇒ Object
Constructor Details
#initialize(trace, method_name, style: :teaching, color: :auto, graph: true) ⇒ Explainer
Returns a new instance of Explainer.
10 11 12 13 14 15 16 |
# File 'lib/why_chain/explainer.rb', line 10 def initialize(trace, method_name, style: :teaching, color: :auto, graph: true) @trace = trace @method_name = method_name @style = style @graph = graph @colorizer = Colorizer.new(color) end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/why_chain/explainer.rb', line 18 def to_s case @style when :teaching TeachingFormatter.new(@method_name, explanation_steps, @graph, @colorizer).render when :compact CompactFormatter.new(@method_name, explanation_steps, @graph, @colorizer).render else raise ArgumentError, "Unknown style: #{@style.inspect}" end end |