class Coco::ColoredString
Public: Build String with ANSI colorization. Do nothing on Windows.
Public Class Methods
new(str = '')
click to toggle source
Public: Initialize a new ColoredString
object.
str - A String.
Calls superclass method
# File lib/coco/formatter/colored_string.rb, line 10 def initialize(str = '') super(str) end
Public Instance Methods
green()
click to toggle source
# File lib/coco/formatter/colored_string.rb, line 28 def green colorize "\033[32m" end
red()
click to toggle source
Public: Make a red string.
Returns String ANSIfied in red.
# File lib/coco/formatter/colored_string.rb, line 17 def red colorize "\033[31m" end
yellow()
click to toggle source
Public: Make a yellow string.
Returns String ANSIfied in yellow.
# File lib/coco/formatter/colored_string.rb, line 24 def yellow colorize "\033[33m" end
Private Instance Methods
colorize(color_code)
click to toggle source
# File lib/coco/formatter/colored_string.rb, line 34 def colorize(color_code) if RUBY_PLATFORM =~ /win32/ self else "#{color_code}#{self}\033[0m" end end