module Term::ANSIColor

def self.coloring=(val)

Term::ANSIColor::coloring = STDOUT.isatty
this for example:
Turns the coloring on or off globally, so you can easily do
def self.coloring=(val)
  @coloring = !!val
end

def self.coloring?

is switched on, false otherwise.
Returns true, if the coloring function of this module
def self.coloring?
  @coloring
end

def self.true_coloring=(val)

Term::ANSIColor::true_coloring = ENV['COLORTERM'] =~ /\A(truecolor|24bit)\z/
colors if your terminal supports it:
Turns the true coloring mode on or off globally, that will display 24-bit
def self.true_coloring=(val)
  @true_coloring = !!val
end

def self.true_coloring?

false otherwise.
Returns true, if the tue coloring mode of this module is switched on,
def self.true_coloring?
  @true_coloring
end

def apply_attribute(name, string = nil, &block)

def apply_attribute(name, string = nil, &block)
  attribute = Attribute[name] or
    raise ArgumentError, "unknown attribute #{name.inspect}"
  apply_code(attribute.code, string, &block)
end

def apply_code(code, string = nil, &block)

def apply_code(code, string = nil, &block)
  result = ''.dup
  result << "\e[#{code}m" if Term::ANSIColor.coloring?
  if block_given?
    result << yield.to_s
  elsif string.respond_to?(:to_str)
    result << string.to_str
  elsif respond_to?(:to_str)
    result << to_str
  else
    return result # only switch on
  end
  result << "\e[0m" if Term::ANSIColor.coloring?
  result.extend(Term::ANSIColor)
end

def color(name, string = nil, &block)

on the color +name+ is returned.
color +name+. If string isn't a string only the escape sequence to switch
Return +string+ or the result string of the given +block+ colored with
def color(name, string = nil, &block)
  apply_attribute(name, string, &block)
end

def on_color(name, string = nil, &block)

escape sequence to switch on the color +name+ is returned.
background colored with color +name+. If string isn't a string only the
Return +string+ or the result string of the given +block+ with a
def on_color(name, string = nil, &block)
  attribute = Attribute[name] or
    raise ArgumentError, "unknown attribute #{name.inspect}"
  attribute = attribute.dup
  attribute.background = true
  apply_attribute(attribute, string, &block)
end

def term_ansicolor_attributes

Returns an array of all Term::ANSIColor attributes as symbols.
def term_ansicolor_attributes
  ::Term::ANSIColor::Attribute.attributes.map(&:name)
end

def term_ansicolor_attributes

Returns an array of all Term::ANSIColor attributes as symbols.
def  term_ansicolor_attributes
  ::Term::ANSIColor.term_ansicolor_attributes
end

def uncolor(string = nil) # :yields:

:yields:
are stripped from the string.
Returns an uncolored version of the string, that is all ANSI-Attributes
def uncolor(string = nil) # :yields:
  if block_given?
    yield.to_str.gsub(COLORED_REGEXP, '')
  elsif string.respond_to?(:to_str)
    string.to_str.gsub(COLORED_REGEXP, '')
  elsif respond_to?(:to_str)
    to_str.gsub(COLORED_REGEXP, '')
  else
    ''.dup
  end.extend(Term::ANSIColor)
end