Sha256: 27e49f99697412d8adef31810a9515dc1d4b793ebfe8ac398cb22043cae70e8c

Contents?: true

Size: 734 Bytes

Versions: 4

Compression:

Stored size: 734 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]
    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 # rubocop:disable AccessModifierIndentation

      # 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

4 entries across 4 versions & 1 rubygems

Version Path
mutant-0.8.16 lib/mutant/color.rb
mutant-0.8.15 lib/mutant/color.rb
mutant-0.8.14 lib/mutant/color.rb
mutant-0.8.13 lib/mutant/color.rb