cute.
>> "this is red".red >> "this is red with a blue background (read: ugly)".red_on_blue >> "this is red with an underline".red.underline >> "this is really bold and really blue".bold.blue >> Colored.red "This is red" # but this part is mostly untested
# File lib/colored.rb, line 83 def color(color_name) background = color_name.to_s =~ /on_/ color_name = color_name.to_s.sub('on_', '') return unless color_name && COLORS[color_name] "\e[#{COLORS[color_name] + (background ? 10 : 0)}m" end
# File lib/colored.rb, line 68 def colorize(string, options = {}) colored = [color(options[:foreground]), color("on_#{options[:background]}"), extra(options[:extra])].compact * '' colored << string colored << extra(:clear) end
Generated with the Darkfish Rdoc Generator 2.