Sha256: 828f7d1e6ecd2c47ec20739b6ee4032ed105b1bb36c41f244338494769a41205

Contents?: true

Size: 444 Bytes

Versions: 4

Compression:

Stored size: 444 Bytes

Contents

require 'ansi/code'

module Mpx
  ##
  # Represents the output of a command.
  class Result
    include ANSI::Code

    def initialize(name, out, status)
      @name = name
      @out = out
      @status = status
    end

    def to_s
      return [cyan { @name }, @out.strip, status_string].join("\n")
    end

    def status_string
      color = @status.exitstatus.zero? ? :green : :red
      return send(color) { @status }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mpx-0.2.0 lib/mpx/result.rb
mpx-0.1.2 lib/mpx/result.rb
mpx-0.1.1 lib/mpx/result.rb
mpx-0.1.0 lib/mpx/result.rb