Class: Riffer::Agent::StructuredOutput::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/riffer/agent/structured_output/result.rb,
sig/generated/riffer/agent/structured_output/result.rbs

Overview

Wraps the result of structured output parsing and validation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object: nil, error: nil) ⇒ Result

-- : (?object: Hash[Symbol, untyped]?, ?error: String?) -> void

Parameters:

  • object: (Hash[Symbol, untyped], nil) (defaults to: nil)
  • error: (String, nil) (defaults to: nil)


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

#errorString? (readonly)

The error message, or nil on success.

Returns:

  • (String, nil)


10
11
12
# File 'lib/riffer/agent/structured_output/result.rb', line 10

def error
  @error
end

#objectHash[Symbol, untyped]? (readonly)

The validated object, or nil on failure.

Returns:

  • (Hash[Symbol, untyped], nil)


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

Returns:

  • (Boolean)


29
# File 'lib/riffer/agent/structured_output/result.rb', line 29

def failure? = !success?

#success?Boolean

Returns true when parsing and validation succeeded.

-- : () -> bool

Returns:

  • (Boolean)


23
# File 'lib/riffer/agent/structured_output/result.rb', line 23

def success? = @error.nil?