Class: Spinup::ColorizedString

Inherits:
String
  • Object
show all
Defined in:
lib/spinup/colorized_string.rb

Constant Summary collapse

COLORS =
{
  red: 31,
  green: 32,
  yellow: 33,
  blue: 34
}

Instance Method Summary collapse

Constructor Details

#initialize(string, color) ⇒ ColorizedString

Returns a new instance of ColorizedString.

Raises:



10
11
12
13
14
# File 'lib/spinup/colorized_string.rb', line 10

def initialize(string, color)
  raise NotImplementedError, "#{color} strings are not supported" if COLORS[color].nil?

  super("\e[#{COLORS[color]}m#{string}\e[0m")
end