Gem Version Build Status Code Climate Test Coverage Issue Count

Colored2

This is a fork of Chris (defunkt) Wanstrath's colored gem, which appears to be no longer supported.

This fork comes with a slightly spruced up syntax and rspecs.

Usage

In addition to the simple syntax of the original gem, which affected only the string to the left of the method call, the "bang" syntax affects a string to the right. If the block or a method argument is provided, the contents is wrapped in the color, and the color is then reset back. If no block or argument is provided, the color is left open-ended, and must be explicitly reset – when using the 'bang' notation.

Usage in Other Classes

You can decorate and color not just strings.

To color numbers, require the following file, which automatically decorates Fixnum and Float. You can also add color methods to the Object. Finally, you can add the methods to any custom class by including the Colored2 Module.

Below is an IRB session that shows a slightly more advanced usage.