Class: Unparser::Color

Inherits:
Object
  • Object
show all
Includes:
Adamantium
Defined in:
lib/unparser/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
  def format(text)
    text
  end

private

  # Well rubocop you are static so you do not have a clue here ;)
  # rubocop:disable Style/RedundantInitialize
  # rubocop:disable Style/MissingSuper
  def initialize; end
  # rubocop:enable Style/RedundantInitialize
  # rubocop:enable Style/MissingSuper

end.new
RED =
Color.new(31)
GREEN =
Color.new(32)

Instance Method Summary collapse

Instance Method Details

#format(text) ⇒ String

Format text with color

Parameters:

  • text (String)

Returns:

  • (String)


13
14
15
# File 'lib/unparser/color.rb', line 13

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