Class: RVM::Shell::Result
- Inherits:
-
Object
- Object
- RVM::Shell::Result
- Defined in:
- lib/rvm/shell/result.rb
Overview
Represents the output of a shell command. This includes the exit status (and the helpful #successful? method) as well accessors for the command and stdout / stderr.
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#raw_status ⇒ Object
readonly
Returns the value of attribute raw_status.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns a value from the outputs environment.
-
#env ⇒ Object
Returns the hash of the environment.
-
#exit_status ⇒ Object
Returns the exit status for the program.
-
#initialize(command, status, stdout, stderr) ⇒ Result
constructor
Creates a new result object with the given details.
-
#successful? ⇒ Boolean
Whether or not the command had a successful exit status.
Constructor Details
#initialize(command, status, stdout, stderr) ⇒ Result
Creates a new result object with the given details.
11 12 13 14 15 16 17 18 |
# File 'lib/rvm/shell/result.rb', line 11 def initialize(command, status, stdout, stderr) @command = command.dup.freeze @raw_status = status @environment = @raw_status["environment"] || {} @successful = (exit_status == 0) @stdout = stdout.freeze @stderr = stderr.freeze end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
8 9 10 |
# File 'lib/rvm/shell/result.rb', line 8 def command @command end |
#raw_status ⇒ Object (readonly)
Returns the value of attribute raw_status.
8 9 10 |
# File 'lib/rvm/shell/result.rb', line 8 def raw_status @raw_status end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
8 9 10 |
# File 'lib/rvm/shell/result.rb', line 8 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
8 9 10 |
# File 'lib/rvm/shell/result.rb', line 8 def stdout @stdout end |
Instance Method Details
#[](key) ⇒ Object
Returns a value from the outputs environment.
31 32 33 |
# File 'lib/rvm/shell/result.rb', line 31 def [](key) env[key.to_s] end |
#env ⇒ Object
Returns the hash of the environment.
21 22 23 |
# File 'lib/rvm/shell/result.rb', line 21 def env @environment end |
#exit_status ⇒ Object
Returns the exit status for the program
36 37 38 |
# File 'lib/rvm/shell/result.rb', line 36 def exit_status @exit_status ||= (Integer(@raw_status["exit_status"]) rescue 1) end |
#successful? ⇒ Boolean
Whether or not the command had a successful exit status.
26 27 28 |
# File 'lib/rvm/shell/result.rb', line 26 def successful? @successful end |