Module: Timber::CLI::IO::ANSI

Defined in:
lib/timber/cli/io/ansi.rb

Class Method Summary collapse

Class Method Details

.colorize(text, color) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/timber/cli/io/ansi.rb', line 5

def self.colorize(text, color)
  return text if Gem.win_platform?

  code =
    case color
    when :blue then 34
    when :red then 31
    when :green then 32
    when :yellow then 33
    else 0
    end

  "\e[#{code}m#{text}\e[0m"
end