Class: RubyLLM::Model::Pricing
- Inherits:
-
Object
- Object
- RubyLLM::Model::Pricing
- 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
-
#initialize(data) ⇒ Pricing
constructor
A new instance of Pricing.
- #method_missing(method, *args) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ Pricing
Returns a new instance of 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 ].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 ].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 |