Class: Riffer::Agent::StructuredOutput::Result
- Inherits:
-
Object
- Object
- Riffer::Agent::StructuredOutput::Result
- Defined in:
- lib/riffer/agent/structured_output/result.rb
Overview
Wraps the result of structured output parsing and validation.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
The error message, or
nilon success. -
#object ⇒ Object
readonly
The validated object, or
nilon failure.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
Returns true when parsing or validation failed.
-
#initialize(object: nil, error: nil) ⇒ Result
constructor
– : (?object: Hash[Symbol, untyped]?, ?error: String?) -> void.
-
#success? ⇒ Boolean
Returns true when parsing and validation succeeded.
Constructor Details
#initialize(object: nil, error: nil) ⇒ Result
– : (?object: Hash[Symbol, untyped]?, ?error: String?) -> void
14 15 16 17 |
# File 'lib/riffer/agent/structured_output/result.rb', line 14 def initialize(object: nil, error: nil) @object = object @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
The error message, or nil on success.
10 11 12 |
# File 'lib/riffer/agent/structured_output/result.rb', line 10 def error @error end |
#object ⇒ Object (readonly)
The validated object, or nil on failure.
7 8 9 |
# File 'lib/riffer/agent/structured_output/result.rb', line 7 def object @object end |
Instance Method Details
#failure? ⇒ Boolean
Returns true when parsing or validation failed.
– : () -> bool
29 |
# File 'lib/riffer/agent/structured_output/result.rb', line 29 def failure? = !success? |
#success? ⇒ Boolean
Returns true when parsing and validation succeeded.
– : () -> bool
23 |
# File 'lib/riffer/agent/structured_output/result.rb', line 23 def success? = @error.nil? |