Sha256: e67c56d1d36a69dffcccd23f5e1d1f4547f86eca34cd474f72b0e519c08e56fc

Contents?: true

Size: 823 Bytes

Versions: 23

Compression:

Stored size: 823 Bytes

Contents

module Mutant
  # Class to colorize strings
  class Color
    include Adamantium::Flat, Concord.new(:code)

    # Format text with color
    #
    # @param [String] text
    #
    # @return [String]
    #
    # @api private
    #
    def format(text)
      "\e[#{@code}m#{text}\e[0m"
    end

    Mutant.singleton_subclass_instance('NONE', self) do

      # Format null color
      #
      # @param [String] text
      #
      # @return [String]
      #   the argument string
      #
      # @api private
      #
      def format(text)
        text
      end

    private

      # Initialize null color
      #
      # @return [undefined]
      #
      # @api private
      #
      def initialize
      end

    end

    RED   = Color.new(31)
    GREEN = Color.new(32)
    BLUE  = Color.new(34)

  end # Color
end # Mutant

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
mutant-0.7.9 lib/mutant/color.rb
mutant-0.7.8 lib/mutant/color.rb
mutant-0.7.7 lib/mutant/color.rb
mutant-0.7.6 lib/mutant/color.rb
mutant-0.7.5 lib/mutant/color.rb
mutant-0.7.4 lib/mutant/color.rb
mutant-0.7.3 lib/mutant/color.rb
mutant-0.7.2 lib/mutant/color.rb
mutant-0.7.1 lib/mutant/color.rb
mutant-0.6.7 lib/mutant/color.rb
mutant-0.6.6 lib/mutant/color.rb
mutant-0.6.5 lib/mutant/color.rb
mutant-0.6.4 lib/mutant/color.rb
mutant-0.6.3 lib/mutant/color.rb
mutant-0.6.2 lib/mutant/color.rb
mutant-0.6.0 lib/mutant/color.rb
mutant-0.5.26 lib/mutant/color.rb
mutant-0.5.25 lib/mutant/color.rb
mutant-0.5.24 lib/mutant/color.rb
mutant-0.5.23 lib/mutant/color.rb