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.


12
13
14
# File 'lib/coco/formatter/colored_string.rb', line 12

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

Instance Method Details

#greenObject


30
31
32
# File 'lib/coco/formatter/colored_string.rb', line 30

def green
  colorize "\033[32m"
end

#redObject

Public: Make a red string.

Returns String ANSIfied in red.


19
20
21
# File 'lib/coco/formatter/colored_string.rb', line 19

def red
  colorize "\033[31m"
end

#yellowObject

Public: Make a yellow string.

Returns String ANSIfied in yellow.


26
27
28
# File 'lib/coco/formatter/colored_string.rb', line 26

def yellow
  colorize "\033[33m"
end