Class: LlmCostTracker::Ledger::Rollups::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/ledger/rollups/batch.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ Batch

Returns a new instance of Batch.



15
16
17
# File 'lib/llm_cost_tracker/ledger/rollups/batch.rb', line 15

def initialize(events)
  @events = events
end

Class Method Details

.rows(events) ⇒ Object



11
12
13
# File 'lib/llm_cost_tracker/ledger/rollups/batch.rb', line 11

def self.rows(events)
  new(events).rows
end

Instance Method Details

#rowsObject



19
20
21
22
23
24
25
26
27
# File 'lib/llm_cost_tracker/ledger/rollups/batch.rb', line 19

def rows
  totals.map do |(period, period_start), total_cost|
    {
      period: period,
      period_start: period_start,
      total_cost: total_cost
    }
  end
end