Skip to content

Instantly share code, notes, and snippets.

@sunny
Created August 18, 2008 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sunny/6073 to your computer and use it in GitHub Desktop.
Save sunny/6073 to your computer and use it in GitHub Desktop.
class String
# ANSI-colored version of the string
def colorize(color)
n = case color
when :black: 30
when :red: 31
when :green: 32
when :yellow: 33
when :blue: 34
when :magenta: 35
when :cyan: 36
when :white: 37
else return self
end
"\033[#{n}m#{self}\033[0m"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment