Sha256: d38e7177696dcae810a6fd5b00cc66b478bc59f331571f1a0b5efa7f08720831
Contents?: true
Size: 729 Bytes
Versions: 2
Compression:
Stored size: 729 Bytes
Contents
module Coco # Public: Build String with ANSI colorization. # Do nothing on Windows. class ColoredString < String # Public: Initialize a new ColoredString object. # # str - A String. def initialize(str = '') super(str) end # Public: Make a red string. # # Returns String ANSIfied in red. def red colorize "\033[31m" end # Public: Make a yellow string. # # Returns String ANSIfied in yellow. def yellow colorize "\033[33m" end def green colorize "\033[32m" end private def colorize(color_code) if RUBY_PLATFORM =~ /win32/ self else "#{color_code}#{self}\033[0m" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
coco-0.15.0 | lib/coco/formatter/colored_string.rb |
coco-0.14.0 | lib/coco/formatter/colored_string.rb |