Class: RubyLLM::Contract::Invariant
- Inherits:
-
Object
- Object
- RubyLLM::Contract::Invariant
- Defined in:
- lib/ruby_llm/contract/contract/invariant.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Instance Method Summary collapse
- #call(parsed_output, input: nil) ⇒ Object
-
#initialize(description, block) ⇒ Invariant
constructor
A new instance of Invariant.
Constructor Details
#initialize(description, block) ⇒ Invariant
Returns a new instance of Invariant.
8 9 10 11 12 |
# File 'lib/ruby_llm/contract/contract/invariant.rb', line 8 def initialize(description, block) @description = description @block = block freeze end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/ruby_llm/contract/contract/invariant.rb', line 6 def description @description end |
Instance Method Details
#call(parsed_output, input: nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ruby_llm/contract/contract/invariant.rb', line 14 def call(parsed_output, input: nil) if @block.arity >= 2 @block.call(parsed_output, input) else @block.call(parsed_output) end end |