Class: RubyLLM::Model::Pricing
- Inherits:
-
Object
- Object
- RubyLLM::Model::Pricing
show all
- Defined in:
- lib/ruby_llm/model/pricing.rb
Overview
A collection that manages and provides access to different categories of pricing information
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Pricing
7
8
9
10
11
12
13
|
# File 'lib/ruby_llm/model/pricing.rb', line 7
def initialize(data)
@data = {}
i[text_tokens images audio_tokens embeddings].each do |category|
@data[category] = PricingCategory.new(data[category]) if data[category] && !empty_pricing?(data[category])
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/ruby_llm/model/pricing.rb', line 15
def method_missing(method, *args)
if respond_to_missing?(method)
@data[method.to_sym] || PricingCategory.new
else
super
end
end
|
Instance Method Details
#respond_to_missing?(method, include_private = false) ⇒ Boolean
23
24
25
|
# File 'lib/ruby_llm/model/pricing.rb', line 23
def respond_to_missing?(method, include_private = false)
i[text_tokens images audio_tokens embeddings].include?(method.to_sym) || super
end
|
#to_h ⇒ Object
27
28
29
|
# File 'lib/ruby_llm/model/pricing.rb', line 27
def to_h
@data.transform_values(&:to_h)
end
|