Class: NexusSW::LXD::Transport::Mixins::Helpers::ExecuteMixin::ExecuteResult
- Inherits:
-
Object
- Object
- NexusSW::LXD::Transport::Mixins::Helpers::ExecuteMixin::ExecuteResult
- Defined in:
- lib/nexussw/lxd/transport/mixins/helpers/execute.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#exitstatus ⇒ Object
readonly
Returns the value of attribute exitstatus.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #error! ⇒ Object
-
#initialize(command, options, exitstatus) ⇒ ExecuteResult
constructor
A new instance of ExecuteResult.
- #stderr ⇒ Object
- #stdout ⇒ Object
Constructor Details
#initialize(command, options, exitstatus) ⇒ ExecuteResult
Returns a new instance of ExecuteResult.
8 9 10 11 12 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 8 def initialize(command, , exitstatus) @command = command @options = || {} @exitstatus = exitstatus end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
14 15 16 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 14 def command @command end |
#exitstatus ⇒ Object (readonly)
Returns the value of attribute exitstatus.
14 15 16 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 14 def exitstatus @exitstatus end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
14 15 16 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 14 def @options end |
Instance Method Details
#error! ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 24 def error! return self if exitstatus == 0 msg = "Error: '#{command}' failed with exit code #{exitstatus}.\n" msg += "STDOUT: #{stdout}" if stdout.is_a?(String) && !stdout.empty? msg += "STDERR: #{stderr}" if stderr.is_a?(String) && !stderr.empty? raise msg end |
#stderr ⇒ Object
20 21 22 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 20 def stderr [:capture_options][:stderr] if .key? :capture_options end |
#stdout ⇒ Object
16 17 18 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/execute.rb', line 16 def stdout [:capture_options][:stdout] if .key? :capture_options end |