class RVM::Shell::Result
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.
Attributes
command[R]
raw_status[R]
stderr[R]
stdout[R]
Public Class Methods
new(command, status, stdout, stderr)
click to toggle source
Creates a new result object with the given details.
# File lib/rvm/shell/result.rb, line 11 def initialize(command, status, stdout, stderr) @command = command.dup.freeze @raw_status = status @environment = (@raw_status ? (@raw_status["environment"] || {}) : {}) @successful = (exit_status == 0) @stdout = stdout.freeze @stderr = stderr.freeze end
Public Instance Methods
[](key)
click to toggle source
Returns a value from the outputs environment.
# File lib/rvm/shell/result.rb, line 31 def [](key) env[key.to_s] end
env()
click to toggle source
Returns the hash of the environment.
# File lib/rvm/shell/result.rb, line 21 def env @environment end
exit_status()
click to toggle source
Returns the exit status for the program
# File lib/rvm/shell/result.rb, line 36 def exit_status @exit_status ||= (Integer(@raw_status["exit_status"]) rescue 1) end
successful?()
click to toggle source
Whether or not the command had a successful exit status.
# File lib/rvm/shell/result.rb, line 26 def successful? @successful end