Class: LlmCostTracker::Report::Formatter
- Inherits:
-
Object
- Object
- LlmCostTracker::Report::Formatter
- Defined in:
- lib/llm_cost_tracker/report/formatter.rb
Constant Summary collapse
- TOP_LIMIT =
5- MIN_COLUMN_WIDTH =
28
Instance Method Summary collapse
-
#initialize(data, color: $stdout.tty?) ⇒ Formatter
constructor
A new instance of Formatter.
- #to_s ⇒ Object
Constructor Details
#initialize(data, color: $stdout.tty?) ⇒ Formatter
Returns a new instance of Formatter.
9 10 11 12 |
# File 'lib/llm_cost_tracker/report/formatter.rb', line 9 def initialize(data, color: $stdout.tty?) @data = data @color = color end |
Instance Method Details
#to_s ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/llm_cost_tracker/report/formatter.rb', line 14 def to_s lines = [bold("LLM Cost Report (last #{@data.days} days)"), ""] append_summary(lines) append_cost_section(lines, "By provider", @data.cost_by_provider) { |row| row.name.to_s } append_cost_section(lines, "By model", @data.cost_by_model) { |row| row.name.to_s } append_tag_sections(lines) append_top_calls(lines) lines.join("\n") end |