Module: RakeCompilerDock::Colors

Included in:
DockerCheck
Defined in:
lib/rake_compiler_dock/colors.rb

Constant Summary collapse

ESC =

Start an escape sequence

"\e["
NND =

End the escape sequence

"#{ESC}0m"
ColorMap =
{
  :black => 0,
  :red => 1,
  :green => 2,
  :yellow => 3,
  :blue => 4,
  :magenta => 5,
  :cyan => 6,
  :white => 7,
}

Instance Method Summary collapse

Instance Method Details

#colored(color, string) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/rake_compiler_dock/colors.rb', line 26

def colored(color, string)
  if @colors_on
    c = ColorMap[color] || color
    "#{ESC}#{30+c}m#{string}#{NND}"
  else
    string.dup
  end
end

#disable_colorsObject



39
40
41
# File 'lib/rake_compiler_dock/colors.rb', line 39

def disable_colors
  @colors_on = false
end

#enable_colorsObject



35
36
37
# File 'lib/rake_compiler_dock/colors.rb', line 35

def enable_colors
  @colors_on = true
end