Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple module for colour output to the terminal.
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
You can’t perform that action at this time.