Created
April 4, 2010 22:34
-
-
Save xoebus/355760 to your computer and use it in GitHub Desktop.
ANSI Colours for Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
[:gray, :red, :green, :yellow, :blue, :purple, :cyan, :white].each_with_index do |color, i| | |
define_method color do "\033[1;#{30+i}m#{self}\033[0m" end | |
define_method :"#{color}ish" do "\033[0;#{30+i}m#{self}\033[0m" end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment