Class: Mistri::Models::RateCard

Inherits:
Data
  • Object
show all
Defined in:
lib/mistri/models.rb

Overview

One request's standard rates and optional prompt-size tier.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#aboveObject (readonly)

Returns the value of attribute above

Returns:

  • (Object)

    the current value of above



14
15
16
# File 'lib/mistri/models.rb', line 14

def above
  @above
end

#higherObject (readonly)

Returns the value of attribute higher

Returns:

  • (Object)

    the current value of higher



14
15
16
# File 'lib/mistri/models.rb', line 14

def higher
  @higher
end

#ratesObject (readonly)

Returns the value of attribute rates

Returns:

  • (Object)

    the current value of 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