SafeColorize
Safe coloring extensions of String.
Description
SafeColorize is implemented by Refinements.
Therefore, it is safer than openclass.
Installation
Add this line to your application's Gemfile:
gem 'safe_colorize'
Requirements
- Ruby 2.1.0 or higher
Usage
require 'safe_colorize'
using SafeColorize
p foo = 'foo'.color(:red).style(:bold) #=> "\e[1m\e[31mfoo\e[0m\e[0m"
p = 'bar'.color(:magenta).bg_color(:blue) #=> "\e[44m\e[35mbar\e[0m\e[0m"
p foo.to_pure #=> "foo"
p .to_pure #=> "bar"
Available symbols
# String#color, String#bg_color
[:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
# String#style
[:reset, :bold, :underscore, :blink, :reverse, :concealed]