Module: YleTf::Logger::Colorize

Defined in:
lib/yle_tf/logger/colorize.rb

Constant Summary collapse

COLORS =
{
  black:   30,
  red:     31,
  brown:   33,
  blue:    34,
  magenta: 35,
  cyan:    36,
  gray:    37
}.freeze

Class Method Summary collapse

Class Method Details

.colorize(msg, color) ⇒ Object

Wraps the message with the specified ANSI color code if the color is specified and supported



16
17
18
19
# File 'lib/yle_tf/logger/colorize.rb', line 16

def self.colorize(msg, color)
  code = COLORS[color]
  code ? "\033[#{code}m#{msg}\033[0m" : msg
end