Ruby Colorized Console

22 March 2007

I wrote a simple ruby string class extension to displays console colors easier using ANSI escape sequences. Links for project page, and documentation page.

Install:

# gem install colorize

Some examples:

puts "This is blue".colorize( :blue )
puts "This is light blue".colorize( :light_blue )
puts "This is also blue".colorize( :color => :blue )
puts "This is blue with red background".colorize( :color => :light_blue, :background => :red )
puts "This is blue with red background".colorize( :light_blue ).colorize( :background => :red )
puts "This is blue text on red".blue.on_red
puts "This is red on blue".colorize( :red ).on_blue
puts "This is uncolorized".blue.on_red.uncolorize

This thing should work on Windows too, but its untested. So if you check it out, please give me some feedback.