free_mutant/lib/mutant/color.rb
Markus Schirp f9d3a275ac Remove Mutant.singleton_subclass_instance
* Only one call side, implementation was inlined
2015-06-13 13:37:25 +00:00

51 lines
801 B
Ruby

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
NONE = Class.new(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.new
RED = Color.new(31)
GREEN = Color.new(32)
BLUE = Color.new(34)
end # Color
end # Mutant