Module: LlmCostTracker::Ledger::Period
- Defined in:
- lib/llm_cost_tracker/ledger.rb,
lib/llm_cost_tracker/ledger/period.rb,
lib/llm_cost_tracker/ledger/period/totals.rb
Defined Under Namespace
Classes: Totals
Constant Summary collapse
- PERIODS =
%i[month day].freeze
Class Method Summary collapse
Class Method Details
.bucket(period, time) ⇒ Object
21 22 23 |
# File 'lib/llm_cost_tracker/ledger/period.rb', line 21 def self.bucket(period, time) range_start(period, time).to_date end |
.range_start(period, time) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/llm_cost_tracker/ledger/period.rb', line 12 def self.range_start(period, time) utc_time = time.to_time.utc case period when :month then utc_time.beginning_of_month when :day then utc_time.beginning_of_day end end |
.valid_keys(periods) ⇒ Object
8 9 10 |
# File 'lib/llm_cost_tracker/ledger/period.rb', line 8 def self.valid_keys(periods) PERIODS & periods end |