Sha256: 3017bdcb10efc4d004910c232a716e419041e64bd6bc47c0edd67c1d7cb8b616

Contents?: true

Size: 641 Bytes

Versions: 6

Compression:

Stored size: 641 Bytes

Contents

# encoding: UTF-8

module Gitenv

  class Status
    TYPES = [ :ok, :missing, :warning, :error ]
    COLORS = { ok: :green, missing: :blue, warning: :yellow, error: :red }

    attr_reader :type, :message

    class << self
      TYPES.each do |m|
        define_method m do |message|
          self.new m, message
        end
      end
    end

    TYPES.each do |m|
      define_method "#{m}?" do
        @type == m
      end
    end

    def marker
      @type == :ok ? "✓" : "✗"
    end

    def color
      COLORS[@type]
    end

    private

    def initialize type, message
      @type, @message = type, message
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gitenv-1.1.0 lib/gitenv/status.rb
gitenv-1.0.4 lib/gitenv/status.rb
gitenv-1.0.0 lib/gitenv/status.rb
gitenv-0.3.0 lib/gitenv/status.rb
gitenv-0.2.0 lib/gitenv/status.rb
gitenv-0.1.0 lib/gitenv/status.rb