Skip to content

Instantly share code, notes, and snippets.

@nejdetkadir
Created January 25, 2022 15:33
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 nejdetkadir/85d207e56fae600e54afebc513b43f13 to your computer and use it in GitHub Desktop.
Save nejdetkadir/85d207e56fae600e54afebc513b43f13 to your computer and use it in GitHub Desktop.
Colorization for ruby strings
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
end
def green
colorize(32)
end
def light_blue
colorize(36)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment