Class: Geminize::Models::CodeExecution::CodeExecutionResult
- Inherits:
-
Object
- Object
- Geminize::Models::CodeExecution::CodeExecutionResult
- Defined in:
- lib/geminize/models/code_execution/code_execution_result.rb
Overview
Represents the result of executed code
Constant Summary collapse
- VALID_OUTCOMES =
Valid outcome values for code execution
["OUTCOME_OK", "OUTCOME_ERROR"].freeze
Instance Attribute Summary collapse
-
#outcome ⇒ String
readonly
The outcome of the code execution (e.g., "OUTCOME_OK", "OUTCOME_ERROR").
-
#output ⇒ String
readonly
The output from the code execution.
Instance Method Summary collapse
-
#initialize(outcome, output) ⇒ CodeExecutionResult
constructor
Initialize a new code execution result.
-
#to_h ⇒ Hash
Alias for to_hash.
-
#to_hash ⇒ Hash
Convert the code execution result to a hash.
-
#validate! ⇒ Boolean
Validate the code execution result.
Constructor Details
#initialize(outcome, output) ⇒ CodeExecutionResult
Initialize a new code execution result
21 22 23 24 25 |
# File 'lib/geminize/models/code_execution/code_execution_result.rb', line 21 def initialize(outcome, output) @outcome = outcome @output = output validate! end |
Instance Attribute Details
#outcome ⇒ String (readonly)
Returns The outcome of the code execution (e.g., "OUTCOME_OK", "OUTCOME_ERROR").
12 13 14 |
# File 'lib/geminize/models/code_execution/code_execution_result.rb', line 12 def outcome @outcome end |
#output ⇒ String (readonly)
Returns The output from the code execution.
15 16 17 |
# File 'lib/geminize/models/code_execution/code_execution_result.rb', line 15 def output @output end |
Instance Method Details
#to_h ⇒ Hash
Alias for to_hash
66 67 68 |
# File 'lib/geminize/models/code_execution/code_execution_result.rb', line 66 def to_h to_hash end |
#to_hash ⇒ Hash
Convert the code execution result to a hash
57 58 59 60 61 62 |
# File 'lib/geminize/models/code_execution/code_execution_result.rb', line 57 def to_hash { outcome: @outcome, output: @output } end |
#validate! ⇒ Boolean
Validate the code execution result
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/geminize/models/code_execution/code_execution_result.rb', line 30 def validate! unless @outcome.is_a?(String) raise Geminize::ValidationError.new( "Outcome must be a string, got #{@outcome.class}", "INVALID_ARGUMENT" ) end unless VALID_OUTCOMES.include?(@outcome) raise Geminize::ValidationError.new( "Invalid outcome: #{@outcome}. Must be one of: #{VALID_OUTCOMES.join(", ")}", "INVALID_ARGUMENT" ) end unless @output.is_a?(String) raise Geminize::ValidationError.new( "Output must be a string, got #{@output.class}", "INVALID_ARGUMENT" ) end true end |