module Sawaal::Color
Methods to colorize output
@api private
Public Instance Methods
bold(str)
click to toggle source
Returns the bold representation
@return [String]
# File lib/sawaal/color.rb, line 32 def bold(str) colorize(str, 1, 22) end
cyan(str)
click to toggle source
Colorize a string with cyan color
@return [String]
# File lib/sawaal/color.rb, line 25 def cyan(str) colorize(str, 36) end
green(str)
click to toggle source
Colorize a string with green color
@return [String]
# File lib/sawaal/color.rb, line 18 def green(str) colorize(str, 32) end
red(str)
click to toggle source
Colorize a string with red color
@return [String]
# File lib/sawaal/color.rb, line 11 def red(str) colorize(str, 31) end
Private Instance Methods
colorize(str, color_code, end_tag = 0)
click to toggle source
Wrap a string in a specific color code
@return [String]
# File lib/sawaal/color.rb, line 41 def colorize(str, color_code, end_tag = 0) "\033[#{color_code}m#{str}\033[#{end_tag}m" end