Created
April 20, 2011 23:13
-
-
Save mebens/933311 to your computer and use it in GitHub Desktop.
Simple module for colour output to the terminal.
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 ColorOutput | |
RED = 31 | |
GREEN = 32 | |
YELLOW = 33 | |
BLUE = 34 | |
MAGENTA = 35 | |
CYAN = 36 | |
def self.wrap(s, start_code, end_code = nil) | |
end_code = start_code - (start_code % 10) + 9 if end_code.nil? | |
"\x1b[#{start_code}m#{s}\x1b[#{end_code}m" | |
end | |
def self.bold(s) | |
wrap(s, 1, 22) | |
end | |
end | |
puts ColorOutput.wrap("Warning! Uh... something's going wrong... don't know what though.", ColorOutput::RED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment