Sha256: 0287467e343ce3cac7e2112839f85add3a4685d9bb7014a740eb10c1cd70ea98

Contents?: true

Size: 842 Bytes

Versions: 24

Compression:

Stored size: 842 Bytes

Contents

# encoding: utf-8

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

24 entries across 24 versions & 1 rubygems

Version Path
mutant-0.5.19 lib/mutant/color.rb
mutant-0.5.18 lib/mutant/color.rb
mutant-0.5.17 lib/mutant/color.rb
mutant-0.5.16 lib/mutant/color.rb
mutant-0.5.15 lib/mutant/color.rb
mutant-0.5.14 lib/mutant/color.rb
mutant-0.5.13 lib/mutant/color.rb
mutant-0.5.12 lib/mutant/color.rb
mutant-0.5.11 lib/mutant/color.rb
mutant-0.5.10 lib/mutant/color.rb
mutant-0.5.9 lib/mutant/color.rb
mutant-0.5.8 lib/mutant/color.rb
mutant-0.5.7 lib/mutant/color.rb
mutant-0.5.6 lib/mutant/color.rb
mutant-0.5.5 lib/mutant/color.rb
mutant-0.5.4 lib/mutant/color.rb
mutant-0.5.3 lib/mutant/color.rb
mutant-0.5.2 lib/mutant/color.rb
mutant-0.5.1 lib/mutant/color.rb
mutant-0.5.0 lib/mutant/color.rb