class TTY::Command::Result
Encapsulates the information on the command executed
@api public
Attributes
err[R]
All data written out to process's stdin stream
out[R]
All data written out to process's stdout stream
runtime[R]
Total command execution time
stderr[R]
All data written out to process's stdin stream
stdout[R]
All data written out to process's stdout stream
Public Class Methods
new(status, out, err, runtime = 0.0)
click to toggle source
Create a result
@api public
# File lib/tty/command/result.rb, line 25 def initialize(status, out, err, runtime = 0.0) @status = status @out = out @err = err @runtime = runtime end
Public Instance Methods
==(other)
click to toggle source
# File lib/tty/command/result.rb, line 84 def ==(other) return false unless other.is_a?(TTY::Command::Result) @status == other.to_i && to_ary == other.to_ary end
each(separator = nil, &block)
click to toggle source
Enumerate over output lines
@param [String] separator
@api public
# File lib/tty/command/result.rb, line 37 def each(separator = nil, &block) sep = separator || TTY::Command.record_separator return unless @out elements = @out.split(sep) if block_given? elements.each(&block) else elements.to_enum end end
exit_status()
click to toggle source
Information on how the process exited
@api public
# File lib/tty/command/result.rb, line 52 def exit_status @status end
Also aliased as: exitstatus, status
exited?()
click to toggle source
# File lib/tty/command/result.rb, line 70 def exited? @status != nil end
Also aliased as: complete?
failure?()
click to toggle source
# File lib/tty/command/result.rb, line 79 def failure? !success? end
Also aliased as: failed?
success?()
click to toggle source
# File lib/tty/command/result.rb, line 75 def success? exited? ? @status.zero? : false end
to_ary()
click to toggle source
# File lib/tty/command/result.rb, line 66 def to_ary [@out, @err] end
to_i()
click to toggle source
# File lib/tty/command/result.rb, line 58 def to_i @status end
to_s()
click to toggle source
# File lib/tty/command/result.rb, line 62 def to_s @status.to_s end