Class: BruteCLI::BufferOutput::StatsBar
- Inherits:
-
Object
- Object
- BruteCLI::BufferOutput::StatsBar
- Defined in:
- lib/brute_cli/buffer_output/stats_bar.rb
Overview
Renderable token / timing / tool-call metrics line.
puts BufferOutput::StatsBar.new(, width: 80)
# => "tokens 150 | in 100 | out 50 | time 45.5s | tools 5"
Instance Method Summary collapse
-
#initialize(metadata, width:) ⇒ StatsBar
constructor
A new instance of StatsBar.
- #to_s ⇒ Object
Constructor Details
#initialize(metadata, width:) ⇒ StatsBar
Returns a new instance of StatsBar.
13 14 15 16 |
# File 'lib/brute_cli/buffer_output/stats_bar.rb', line 13 def initialize(, width:) @metadata = @width = width end |
Instance Method Details
#to_s ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/brute_cli/buffer_output/stats_bar.rb', line 18 def to_s tokens = @metadata[:tokens] || {} timing = @metadata[:timing] || {} tool_calls = @metadata[:tool_calls] || 0 sep = " | ".colorize(DIM) parts = [] parts << stat_span("tokens", (tokens[:total] || 0).to_s) parts << stat_span("in", (tokens[:total_input] || 0).to_s) parts << stat_span("out", (tokens[:total_output] || 0).to_s) parts << stat_span("time", format_time(timing[:total_elapsed] || 0)) parts << stat_span("tools", tool_calls.to_s) if tool_calls > 0 parts.join(sep) end |