Class: Smith::Tool::CallBudget
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Smith::Tool::CallBudget
- Defined in:
- lib/smith/tool/call_budget.rb
Class Method Summary collapse
Instance Method Summary collapse
- #exact? ⇒ Boolean
-
#initialize ⇒ CallBudget
constructor
A new instance of CallBudget.
- #limit_for(tool_name) ⇒ Object
Constructor Details
#initialize ⇒ CallBudget
Returns a new instance of CallBudget.
28 29 30 31 32 33 |
# File 'lib/smith/tool/call_budget.rb', line 28 def initialize(...) super validate_tool_limits! tool_limits&.freeze freeze end |
Class Method Details
.coerce(value) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/smith/tool/call_budget.rb', line 21 def self.coerce(value) return value if value.is_a?(self) return new(total: value) if value.is_a?(Integer) raise ArgumentError, "tool call budget must be an integer or Smith::Tool::CallBudget" end |
Instance Method Details
#exact? ⇒ Boolean
35 |
# File 'lib/smith/tool/call_budget.rb', line 35 def exact? = !tool_limits.nil? |
#limit_for(tool_name) ⇒ Object
37 38 39 |
# File 'lib/smith/tool/call_budget.rb', line 37 def limit_for(tool_name) tool_limits&.fetch(tool_name.to_s, nil) end |