Class: Unparser::Color

Inherits:
Object
  • Object
show all
Includes:
Adamantium::Flat
Defined in:
lib/unparser/cli/color.rb

Overview

Class to colorize strings

Constant Summary collapse

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)

Instance Method Summary collapse

Instance Method Details

#format(text) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Format text with color

Parameters:

  • text (String)

Returns:

  • (String)


16
17
18
# File 'lib/unparser/cli/color.rb', line 16

def format(text)
  "\e[#{@code}m#{text}\e[0m"
end