If you want to have color strings for Unix Ruby string and you don't want to use gem like colorize
Created
October 15, 2019 11:18
-
-
Save equivalent/74b1dec423f186c6e594f00b9aacff10 to your computer and use it in GitHub Desktop.
ruby collor string
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
class String | |
def red; "\e[#{31}m#{self}\e[0m"; end | |
def green; "\e[#{32}m#{self}\e[0m"; end | |
def yellow; "\e[#{33}m#{self}\e[0m"; end | |
def blue; "\e[#{34}m#{self}\e[0m"; end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment