class SystemCall::Result
A class that represents a result of a system call.
@!attribute [r] exit_status
@return [Process::Status] The exit status of the result.
@!attribute [r] success_result
@return [String] The STDOUT of the result.
@!attribute [r] error_result
@return [String] The STDERR of the result.
Attributes
Public Class Methods
Initializes a new {Result}.
@param exit_status
[Process::Status] The exit status of the result. @param success_result
[String] The STDOUT of the result. @param error_result
[String] The STDERR of the result.
# File lib/system_call/result.rb, line 24 def initialize(exit_status, success_result, error_result) @exit_status = exit_status @success_result = success_result @error_result = error_result end
Public Instance Methods
Compares the result with the result of {#to_s} from another object.
@param other [#to_s, nil] @return [Integer, nil]
# File lib/system_call/result.rb, line 70 def <=>(other) return nil if other.nil? result <=> other.to_s end
Indicates whether the command has not been executed successfully.
@return [Boolean]
# File lib/system_call/result.rb, line 50 def error? !success? end
Gets the exit code of the process.
@return [Integer]
# File lib/system_call/result.rb, line 34 def exit_code exit_status.exitstatus end
Returns the command result.
@return [String] Returns result from {#success_result} when command exited
successfully. Otherwise returns result from {#error_result}.
# File lib/system_call/result.rb, line 59 def result success? ? success_result : error_result end
Indicates whether the command has been executed successfully.
@return [Boolean]
# File lib/system_call/result.rb, line 42 def success? exit_status.success? end