Class: Mistri::Models::RateCard
- Inherits:
-
Data
- Object
- Data
- Mistri::Models::RateCard
- Defined in:
- lib/mistri/models.rb
Overview
One request's standard rates and optional prompt-size tier.
Instance Attribute Summary collapse
-
#above ⇒ Object
readonly
Returns the value of attribute above.
-
#higher ⇒ Object
readonly
Returns the value of attribute higher.
-
#rates ⇒ Object
readonly
Returns the value of attribute rates.
Instance Method Summary collapse
-
#initialize(rates:, above: nil, higher: nil) ⇒ RateCard
constructor
A new instance of RateCard.
- #rates_for(usage) ⇒ Object
Constructor Details
#initialize(rates:, above: nil, higher: nil) ⇒ RateCard
Returns a new instance of RateCard.
15 16 17 18 19 20 21 |
# File 'lib/mistri/models.rb', line 15 def initialize(rates:, above: nil, higher: nil) if above.nil? != higher.nil? raise ArgumentError, "a pricing threshold needs both above and higher" end super(rates: rates.freeze, above:, higher: higher&.freeze) end |
Instance Attribute Details
#above ⇒ Object (readonly)
Returns the value of attribute above
14 15 16 |
# File 'lib/mistri/models.rb', line 14 def above @above end |
#higher ⇒ Object (readonly)
Returns the value of attribute higher
14 15 16 |
# File 'lib/mistri/models.rb', line 14 def higher @higher end |
#rates ⇒ Object (readonly)
Returns the value of attribute rates
14 15 16 |
# File 'lib/mistri/models.rb', line 14 def rates @rates end |
Instance Method Details
#rates_for(usage) ⇒ Object
23 24 25 |
# File 'lib/mistri/models.rb', line 23 def rates_for(usage) usage && above && usage.prompt_tokens > above ? higher : rates end |