Skip to content

Instantly share code, notes, and snippets.

@jamesp
Created November 10, 2008 03:20
Show Gist options
  • Save jamesp/23412 to your computer and use it in GitHub Desktop.
Save jamesp/23412 to your computer and use it in GitHub Desktop.
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