Class: E2B::Services::CommandResult
- Inherits:
-
Object
- Object
- E2B::Services::CommandResult
- Defined in:
- lib/e2b/services/command_handle.rb
Overview
Result of a command execution in the sandbox.
Returned by E2B::Services::CommandHandle#wait when the command finishes successfully.
Instance Attribute Summary collapse
-
#error ⇒ String?
readonly
Error message from command execution, if any.
-
#exit_code ⇒ Integer
readonly
Exit code of the command (0 indicates success).
-
#stderr ⇒ String
readonly
Standard error accumulated from the command.
-
#stdout ⇒ String
readonly
Standard output accumulated from the command.
Instance Method Summary collapse
-
#initialize(stdout: "", stderr: "", exit_code: 0, error: nil) ⇒ CommandResult
constructor
A new instance of CommandResult.
-
#output ⇒ String
Combined output (stdout + stderr).
-
#success? ⇒ Boolean
Check if the command finished successfully.
- #to_s ⇒ String (also: #inspect)
Constructor Details
#initialize(stdout: "", stderr: "", exit_code: 0, error: nil) ⇒ CommandResult
Returns a new instance of CommandResult.
91 92 93 94 95 96 |
# File 'lib/e2b/services/command_handle.rb', line 91 def initialize(stdout: "", stderr: "", exit_code: 0, error: nil) @stdout = stdout @stderr = stderr @exit_code = exit_code @error = error end |
Instance Attribute Details
#error ⇒ String? (readonly)
Returns Error message from command execution, if any.
85 86 87 |
# File 'lib/e2b/services/command_handle.rb', line 85 def error @error end |
#exit_code ⇒ Integer (readonly)
Returns Exit code of the command (0 indicates success).
82 83 84 |
# File 'lib/e2b/services/command_handle.rb', line 82 def exit_code @exit_code end |
#stderr ⇒ String (readonly)
Returns Standard error accumulated from the command.
79 80 81 |
# File 'lib/e2b/services/command_handle.rb', line 79 def stderr @stderr end |
#stdout ⇒ String (readonly)
Returns Standard output accumulated from the command.
76 77 78 |
# File 'lib/e2b/services/command_handle.rb', line 76 def stdout @stdout end |
Instance Method Details
#output ⇒ String
Combined output (stdout + stderr).
108 109 110 |
# File 'lib/e2b/services/command_handle.rb', line 108 def output "#{@stdout}#{@stderr}" end |
#success? ⇒ Boolean
Check if the command finished successfully.
101 102 103 |
# File 'lib/e2b/services/command_handle.rb', line 101 def success? @exit_code == 0 && @error.nil? end |
#to_s ⇒ String Also known as: inspect
113 114 115 |
# File 'lib/e2b/services/command_handle.rb', line 113 def to_s "#<#{self.class.name} exit_code=#{@exit_code} stdout=#{@stdout.bytesize}B stderr=#{@stderr.bytesize}B>" end |