Colorize::Object(T)
A colorized object. Colors and text decorations can be modified.
Constructors
new(object : T)
SourceInstance methods
ansi_escape
Prints the ANSI escape codes for an object. Note that this has no effect on a Colorize::Object with content,
only the escape codes.
require "colorize"
Colorize.with.red.ansi_escape # => "\e[31m"
"hello world".green.bold.ansi_escape # => "\e[32;1m"
back(back : Color) : self
Sourceblack
Sourceblue
Sourcecyan
Sourcedark_gray
Sourcedefault
Sourcefore(fore : Color) : self
Sourcegreen
Sourcelight_blue
Sourcelight_cyan
Sourcelight_gray
Sourcelight_green
Sourcelight_magenta
Sourcelight_red
Sourcelight_yellow
Sourcemagenta
Sourceon_black
Sourceon_blue
Sourceon_cyan
Sourceon_dark_gray
Sourceon_default
Sourceon_green
Sourceon_light_blue
Sourceon_light_cyan
Sourceon_light_gray
Sourceon_light_green
Sourceon_light_magenta
Sourceon_light_red
Sourceon_light_yellow
Sourceon_magenta
Sourceon_red
Sourceon_white
Sourceon_yellow
Sourcered
Sourcesurround(io = STDOUT, &)
Surrounds io by the ANSI escape codes and lets you build colored strings:
require "colorize"
io = IO::Memory.new
Colorize.with.red.surround(io) do
io << "colorful"
Colorize.with.green.bold.surround(io) do
io << " hello "
end
Colorize.with.blue.surround(io) do
io << "world"
end
io << " string"
end
io.to_s # returns a colorful string where "colorful" is red, "hello" green, "world" blue and " string" red again
white
Sourceyellow
Source