Skip to content

Instantly share code, notes, and snippets.

@aalin
Created February 22, 2010 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aalin/311107 to your computer and use it in GitHub Desktop.
Save aalin/311107 to your computer and use it in GitHub Desktop.
class String
COLORS = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
def colorize(color)
value = case color
when Symbol
COLORS.index(color) || 0
else
color
end
"\e[9#{ value }m#{ self }\e[0m"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment