Module: ANSI::Color

Defined in:
lib/ansi/color.rb

Overview

Defines various ANSI escape sequences relating to terminal color manipulation.

A few low-level methods are defined:

  • set_color(*values)

    • takes 1 or more numeric color/attribute codes and produces the appropriate escape sequence.

  • reset_color

    • takes no arguments and resets terminal color and attributes to normal.

A number of higher-level methods are defined. None of them take any arguments, and they have the effect that their name implies:

Attribute methods:

regular    (same as reset_color)
bold
underscore
blink
reverse_video
concealed

Foreground color methods:

black   / fg_black
red     / fg_red
green   / fg_green
yellow  / fg_yellow
blue    / fg_blue
magenta / fg_magenta
cyan    / fg_cyan
white   / fg_white

Background color methods:

bg_black
bg_red
bg_green
bg_yellow
bg_blue
bg_magenta
bg_cyan
bg_white

Every combination of the above is also generated as a single method call, producing results including (but not limited to):

regular_red
bold_red
underscore_red
blink_red
reverse_video_red
concealed_red
red_on_white / regular_red_on_white
bold_red_on_white
underscore_red_on_white
blink_red_on_white
. . .