Created
November 10, 2008 03:20
-
-
Save jamesp/23412 to your computer and use it in GitHub Desktop.
This file contains 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
module ColourfulPuts | |
def cprint(text, colour) | |
colours = { | |
:red => "\033[1;31m", | |
:yellow => "\033[1;31m", | |
:green => "\033[1;32m", | |
:blue => "\033[1;34m", | |
:magenta => "\033[1;35m", | |
:default => "\033[0m" | |
} | |
print colours[colour], text, colours[:default] | |
end | |
def cputs(text, colour) | |
colours = { | |
:red => "\033[1;31m", | |
:yellow => "\033[1;31m", | |
:green => "\033[1;32m", | |
:blue => "\033[1;34m", | |
:magenta => "\033[1;35m", | |
:default => "\033[0m" | |
} | |
print colours[colour] | |
print text.map {|t| print t, "\n"} | |
print colours[:default] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment