Class: LlmCostTracker::Ledger::Period::Totals

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/ledger/period/totals.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(periods, time:) ⇒ Totals

Returns a new instance of Totals.



13
14
15
16
# File 'lib/llm_cost_tracker/ledger/period/totals.rb', line 13

def initialize(periods, time:)
  @periods = Period.valid_keys(periods)
  @time = time
end

Class Method Details

.call(periods, time:) ⇒ Object



9
10
11
# File 'lib/llm_cost_tracker/ledger/period/totals.rb', line 9

def self.call(periods, time:)
  new(periods, time: time).totals
end

Instance Method Details

#totalsObject



18
19
20
21
22
# File 'lib/llm_cost_tracker/ledger/period/totals.rb', line 18

def totals
  return {} if periods.empty?

  snapshot_totals
end