Class: Coco::ColoredString

Inherits:
String
  • Object
show all
Defined in:
lib/coco/formatter/colored_string.rb

Overview

Public: Build String with ANSI colorization. Do nothing on Windows.

Instance Method Summary collapse

Constructor Details

#initialize(str = '') ⇒ ColoredString

Public: Initialize a new ColoredString object.

str - A String.



10
11
12
# File 'lib/coco/formatter/colored_string.rb', line 10

def initialize(str = '')
  super(str)
end

Instance Method Details

#greenObject



28
29
30
# File 'lib/coco/formatter/colored_string.rb', line 28

def green
  colorize "\033[32m"
end

#redObject

Public: Make a red string.

Returns String ANSIfied in red.



17
18
19
# File 'lib/coco/formatter/colored_string.rb', line 17

def red
  colorize "\033[31m"
end

#yellowObject

Public: Make a yellow string.

Returns String ANSIfied in yellow.



24
25
26
# File 'lib/coco/formatter/colored_string.rb', line 24

def yellow
  colorize "\033[33m"
end