A colorized object. Colors and text decorations can be modified.
Same as #ansi_escape but writes to a given io.
Prints the ANSI escape codes for an object.
Apply text decoration Mode::Blink.
Apply text decoration Mode::BlinkFast.
Apply text decoration Mode::Bold.
Apply text decoration Mode::Bright.
Apply text decoration Mode::Dim.
Apply text decoration Mode::DoubleUnderline.
Apply text decoration Mode::Hidden.
Inspects this object and makes the ANSI escape codes visible.
Apply text decoration Mode::Italic.
Adds mode to the text's decorations.
Apply text decoration Mode::Overline.
Apply text decoration Mode::Reverse.
Apply text decoration Mode::Strikethrough.
Surrounds io by the ANSI escape codes and lets you build colored strings:
Appends this object colored and with text decoration to io.
Enables or disables colors and text decoration on this object.
Apply text decoration Mode::Underline.
Struct
Struct
Value
Object
Object
Object
Same as #ansi_escape but writes to a given io.
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"
Apply text decoration Mode::Blink.
Apply text decoration Mode::BlinkFast.
Apply text decoration Mode::Bold.
Apply text decoration Mode::Bright.
Apply text decoration Mode::DoubleUnderline.
Apply text decoration Mode::Italic.
Apply text decoration Mode::Overline.
Apply text decoration Mode::Reverse.
Apply text decoration Mode::Strikethrough.
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 Enables or disables colors and text decoration on this object.
Apply text decoration Mode::Underline.
© 2012–2026 Manas Technology Solutions.
Licensed under the Apache License, Version 2.0.
https://crystal-lang.org/api/1.19.0/Colorize/Object.html