Class RVM::Shell::Result
In: lib/rvm/shell/result.rb
Parent: Object

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.

Methods

[]   env   exit_status   new   successful?  

Attributes

command  [R] 
raw_status  [R] 
stderr  [R] 
stdout  [R] 

Public Class methods

Creates a new result object with the given details.

[Source]

# 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

Public Instance methods

Returns a value from the outputs environment.

[Source]

# File lib/rvm/shell/result.rb, line 31
      def [](key)
        env[key.to_s]
      end

Returns the hash of the environment.

[Source]

# File lib/rvm/shell/result.rb, line 21
      def env
        @environment
      end

Returns the exit status for the program

[Source]

# File lib/rvm/shell/result.rb, line 36
      def exit_status
        @exit_status ||= (Integer(@raw_status["exit_status"]) rescue 1)
      end

Whether or not the command had a successful exit status.

[Source]

# File lib/rvm/shell/result.rb, line 26
      def successful?
        @successful
      end

[Validate]