Class: Smith::Tool::CallBatch
- Inherits:
-
Object
- Object
- Smith::Tool::CallBatch
- Defined in:
- lib/smith/tool/call_batch.rb
Instance Attribute Summary collapse
-
#counts ⇒ Object
readonly
Returns the value of attribute counts.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(size:, counts:) ⇒ CallBatch
constructor
A new instance of CallBatch.
Constructor Details
#initialize(size:, counts:) ⇒ CallBatch
Returns a new instance of CallBatch.
40 41 42 43 44 |
# File 'lib/smith/tool/call_batch.rb', line 40 def initialize(size:, counts:) @size = size @counts = counts freeze end |
Instance Attribute Details
#counts ⇒ Object (readonly)
Returns the value of attribute counts.
6 7 8 |
# File 'lib/smith/tool/call_batch.rb', line 6 def counts @counts end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
6 7 8 |
# File 'lib/smith/tool/call_batch.rb', line 6 def size @size end |
Class Method Details
.coerce(value, exact:) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/smith/tool/call_batch.rb', line 8 def self.coerce(value, exact:) return from_size(value, exact:) if value.is_a?(Integer) raise ArgumentError, "tool call batch size must be a positive integer" unless value.is_a?(Array) names = value.map { canonical_tool_name(_1) } validate_size!(names.length) new(size: names.length, counts: names.tally.freeze) end |