Method: Common::Color#printf_color

Defined in:
lib/common/color.rb

#printf_color(text, color, bold, stdout = STDOUT) ⇒ Object

Print a color text.

Parameters:

  • text

    The text to color.

  • color

    The color.

  • bold

    Precise if we want to set the text in bold.

  • stdout (defaults to: STDOUT)

    The output standard.

Author:

  • tmarmin



16
17
18
19
20
21
22
23
24
25
# File 'lib/common/color.rb', line 16

def printf_color(text, color, bold, stdout = STDOUT)
  # set bold
  if bold == nil || bold == false || bold == 0
    bold=0
  else
    bold=1
  end

  stdout.printf("\033[%d;%dm%s\033[0m", bold, color, text)
end