Module: ColorText

Included in:
Formatter
Defined in:
lib/log_parser/color_text.rb

Overview

Changes text color

Constant Summary collapse

COLOR_CODE =
{ black: 30,
red: 31,
green: 32,
yellow: 33,
blue: 34,
magenta: 35,
cyan: 36,
gray: 37,
white: 38 }.freeze

Instance Method Summary collapse

Instance Method Details

#colorize(text, color) ⇒ Object



15
16
17
# File 'lib/log_parser/color_text.rb', line 15

def colorize(text, color)
  "\e[#{COLOR_CODE[color]}m#{text}\e[0m"
end

#colorize_if(text, color, change_color = false) ⇒ Object



19
20
21
# File 'lib/log_parser/color_text.rb', line 19

def colorize_if(text, color, change_color = false)
  change_color ? colorize(text, color) : text
end