How can I use Ruby to colorize the text output to a terminal?

Viewed 165960

Using Ruby, how can I perform background and foreground text colorization for output in the terminal?

I remember, when programming Pascal we all used to write our own textcolor(…) procedures to make our small educational programs look more pretty and presentational.

How would I go about coding an equivalent of that in Ruby? Is there any built-in support in the core library that lends itself to this? If not, what would be an idiomatic way to add it?

11 Answers
Related