Sha256: d23b3f9e4837551c65b570e4f78284dafda59f13d5e8c4ee485289648f0b8b16

Contents?: true

Size: 721 Bytes

Versions: 17

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

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

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

    NONE = Class.new(self) do

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

    private

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

    end.new

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

  end # Color
end # Mutant

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mutant-0.9.8 lib/mutant/color.rb
mutant-0.9.7 lib/mutant/color.rb
mutant-0.9.6 lib/mutant/color.rb
mutant-0.9.5 lib/mutant/color.rb
mutant-0.9.4 lib/mutant/color.rb
mutant-0.9.3 lib/mutant/color.rb
mutant-0.9.2 lib/mutant/color.rb
mutant-0.9.1 lib/mutant/color.rb
mutant-0.9.0 lib/mutant/color.rb
mutant-0.8.24 lib/mutant/color.rb
mutant-0.8.23 lib/mutant/color.rb
mutant-0.8.22 lib/mutant/color.rb
mutant-0.8.21 lib/mutant/color.rb
mutant-0.8.20 lib/mutant/color.rb
mutant-0.8.19 lib/mutant/color.rb
mutant-0.8.18 lib/mutant/color.rb
mutant-0.8.17 lib/mutant/color.rb