Module: String::ANSI

Included in:
String
Defined in:
lib/spark/core_ext/string.rb

Overview

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

Constant Summary collapse

Colours =

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

[
  :black,
  :red,
  :green,
  :yellow,
  :blue,
  :magenta,
  :cyan,
  :white
]

Instance Method Summary collapse

Instance Method Details

#wrap_ansi(code) ⇒ Object

Wraps this string in the given ANSI code.



28
29
30
# File 'lib/spark/core_ext/string.rb', line 28

def wrap_ansi code
  "\033#{code}#{self}\033[0m"
end