Module: RubyInstaller::Build::Colors

Included in:
RubyInstaller::Build::Components::Base
Defined in:
lib/ruby_installer/build/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



27
28
29
30
31
32
33
34
# File 'lib/ruby_installer/build/colors.rb', line 27

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

#disable_colorsObject



40
41
42
# File 'lib/ruby_installer/build/colors.rb', line 40

def disable_colors
  @colors_on = false
end

#enable_colorsObject



36
37
38
# File 'lib/ruby_installer/build/colors.rb', line 36

def enable_colors
  @colors_on = true
end