module String::ANSI

Provides some methods to colourize strings for output to the terminal.

Constants

Colours

The available ANSI colour codes. The index in the array is the ANSI code.

Public Instance Methods

wrap_ansi(code) click to toggle source

Wraps this string in the given ANSI code.

# File lib/spark/core_ext/string.rb, line 28
def wrap_ansi code
  "\033#{code}#{self}\033[0m"
end