Module: Mago::Cli::Colorize

Included in:
Formatter
Defined in:
lib/mago/cli/colorize.rb

Overview

Provides methods to colorize strings with ANSI colors.

Instance Method Summary collapse

Instance Method Details

#colorize(text, color_code) ⇒ String

Colorize text using a passed code

Parameters:

  • text (String)
  • color_code (Integer)

Returns:

  • (String)

    colorized text



11
12
13
# File 'lib/mago/cli/colorize.rb', line 11

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

#green(text) ⇒ Object

:nodoc:



21
22
23
# File 'lib/mago/cli/colorize.rb', line 21

def green(text)
  colorize(text, 32)
end

#pink(text) ⇒ Object

:nodoc:



31
32
33
# File 'lib/mago/cli/colorize.rb', line 31

def pink(text)
  colorize(text, 35)
end

#red(text) ⇒ Object

:nodoc:



16
17
18
# File 'lib/mago/cli/colorize.rb', line 16

def red(text)
  colorize(text, 31)
end

#yellow(text) ⇒ Object

:nodoc:



26
27
28
# File 'lib/mago/cli/colorize.rb', line 26

def yellow(text)
  colorize(text, 33)
end