class CommandLine::Result
The result returned from running {CommandLine.command_line}.
Attributes
stderr[R]
The complete contents of stderr after running the application.
@example
command_line('grep').stderr # => "usage: grep ..."
@return [String]
stdout[R]
The complete contents of stdout after running the application.
@example
command_line('echo', 'hi').stdout # => "hi\n"
@return [String]
Public Class Methods
new(stdout, stderr, status)
click to toggle source
# File lib/command_line/result.rb, line 6 def initialize(stdout, stderr, status) @stdout = stdout @stderr = stderr @status = status end
Public Instance Methods
exited?()
click to toggle source
Returns `true` if the application exited normally.
@example
command_line('grep').exited?
@return [Boolean]
# File lib/command_line/result.rb, line 36 def exited? @status.exited? end
exitstatus()
click to toggle source
The numeric exit status of the application if it exited normally.
@example
command_line('echo', 'hi').exitstatus # => 0 command_line('grep').exitstatus # => 2
@return [Integer, nil]
# File lib/command_line/result.rb, line 49 def exitstatus @status.exitstatus end
failure?()
click to toggle source
Returns `true` if the command failed to exit normally or exited with a failing status.
@example
command_line('grep').failure? # => true
@return [Boolean]
# File lib/command_line/result.rb, line 72 def failure? !success? end
success?()
click to toggle source
Returns `true` if the command exited normally with a success status.
@example
command_line('echo', 'hi').success? # => true
@return [Boolean]
# File lib/command_line/result.rb, line 60 def success? !@status.nil? && @status.success? end