Skip to content

Instantly share code, notes, and snippets.

@KINGSABRI
Created August 4, 2013 18:15
Show Gist options
  • Select an option

  • Save KINGSABRI/6151293 to your computer and use it in GitHub Desktop.

Select an option

Save KINGSABRI/6151293 to your computer and use it in GitHub Desktop.
colorizing
module Xss
module Ui
module Console
module Prints
module Color
#
# Colorize String class extension.
#
class String
def red; colorize(self, "\e[1m\e[31m"); end
def green; colorize(self, "\e[1m\e[32m"); end
def dark_green; colorize(self, "\e[32m"); end
def yellow; colorize(self, "\e[1m\e[33m"); end
def blue; colorize(self, "\e[1m\e[34m"); end
def dark_blue; colorize(self, "\e[34m"); end
def pur; colorize(self, "\e[1m\e[35m"); end
def bold; colorize(self, "\e[1m"); end
def colorize(text, color_code) "#{color_code}#{text}\e[0m" end
end
end # Color
end # Print
end # Console
end # Ui
end # XSS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment