Class: Psychic::Shell::ExecutionResult
- Inherits:
-
Object
- Object
- Psychic::Shell::ExecutionResult
- Includes:
- Util::Hashable
- Defined in:
- lib/psychic/shell/execution_result.rb
Instance Attribute Summary collapse
-
#exitstatus ⇒ Object
readonly
Returns the value of attribute exitstatus.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #error! ⇒ Object
-
#initialize(results) ⇒ ExecutionResult
constructor
A new instance of ExecutionResult.
- #to_s ⇒ Object
Methods included from Util::Hashable
Constructor Details
#initialize(results) ⇒ ExecutionResult
Returns a new instance of ExecutionResult.
17 18 19 20 21 22 |
# File 'lib/psychic/shell/execution_result.rb', line 17 def initialize(results) @exitstatus = results.fetch(:exitstatus) # Needs to be UTF-8 to serialize as YAML @stdout = results.fetch(:stdout).force_encoding('utf-8') @stderr = results.fetch(:stderr).force_encoding('utf-8') end |
Instance Attribute Details
#exitstatus ⇒ Object (readonly)
Returns the value of attribute exitstatus.
10 11 12 |
# File 'lib/psychic/shell/execution_result.rb', line 10 def exitstatus @exitstatus end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
12 13 14 |
# File 'lib/psychic/shell/execution_result.rb', line 12 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
11 12 13 |
# File 'lib/psychic/shell/execution_result.rb', line 11 def stdout @stdout end |
Instance Method Details
#error! ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/psychic/shell/execution_result.rb', line 24 def error! if @exitstatus != 0 error = ExecutionError.new error.execution_result = self fail error end end |
#to_s ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/psychic/shell/execution_result.rb', line 32 def to_s ''" Execution Result: exitstatus: #{exitstatus} stdout: #{stdout} stderr: #{stderr} "'' end |