Class: Mpx::Result
Overview
Represents the output of a command.
Instance Method Summary collapse
-
#initialize(name, out, status) ⇒ Result
constructor
A new instance of Result.
- #status_string ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, out, status) ⇒ Result
Returns a new instance of Result.
9 10 11 12 13 |
# File 'lib/mpx/result.rb', line 9 def initialize(name, out, status) @name = name @out = out.strip @status = status end |
Instance Method Details
#status_string ⇒ Object
26 27 28 29 30 31 |
# File 'lib/mpx/result.rb', line 26 def status_string status = @status.exitstatus color = status.zero? ? :green : :red = status.zero? ? 'Done!' : "Exited with code #{status}." return send(color) { } end |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mpx/result.rb', line 15 def to_s out = @out.empty? ? yellow { 'No output.' } : @out return [ cyan { @name }, cyan { '-' * @name.length }, out, '', status_string ].join("\n") end |