Class: WhyChain::Explainer::CompactFormatter
- Inherits:
-
Object
- Object
- WhyChain::Explainer::CompactFormatter
- Defined in:
- lib/why_chain/explainer/compact_formatter.rb
Overview
Compact debug-friendly explanation format.
Instance Method Summary collapse
-
#initialize(method_name, steps, graph, colorizer) ⇒ CompactFormatter
constructor
A new instance of CompactFormatter.
- #render ⇒ Object
Constructor Details
#initialize(method_name, steps, graph, colorizer) ⇒ CompactFormatter
Returns a new instance of CompactFormatter.
7 8 9 10 11 12 |
# File 'lib/why_chain/explainer/compact_formatter.rb', line 7 def initialize(method_name, steps, graph, colorizer) @method_name = method_name @steps = steps @graph = graph @colorizer = colorizer end |
Instance Method Details
#render ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/why_chain/explainer/compact_formatter.rb', line 14 def render lines = [@colorizer.colorize("WhyChain :#{@method_name}", :title)] @steps.each_with_index do |step, index| lines << step_line(step, index) lines << @colorizer.colorize(" -> super", :arrow) if @graph && index < @steps.length - 1 end lines.join("\n") end |