Created
September 10, 2012 17:52
-
-
Save ajjames/3692512 to your computer and use it in GitHub Desktop.
Simple extension of ruby string class to add coloring.
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
CLEAR = "\033[0m" | |
BOLD = "\033[1m" | |
BLACK = "\033[30m" | |
GREEN = "\033[32m" | |
RED = "\033[31m" | |
YELLOW = "\033[33m" | |
BLUE = "\033[34m" | |
MAGENTA = "\033[35m" | |
CYAN = "\033[36m" | |
WHITE = "\033[37m" | |
class String | |
def bold | |
BOLD+ self + CLEAR | |
end | |
def black | |
BLACK + self + CLEAR | |
end | |
def red | |
RED + self + CLEAR | |
end | |
def green | |
GREEN + self + CLEAR | |
end | |
def yellow | |
YELLOW + self + CLEAR | |
end | |
def blue | |
BLUE + self + CLEAR | |
end | |
def magenta | |
MAGENTA + self + CLEAR | |
end | |
def cyan | |
CYAN + self + CLEAR | |
end | |
def white | |
WHITE + self + CLEAR | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment