module Fasterer::Painter
Constants
- COLOR_CODES
Public Class Methods
paint(string, color)
click to toggle source
# File lib/fasterer/painter.rb, line 8 def self.paint(string, color) color_code = COLOR_CODES[color.to_sym] if color_code.nil? raise ArgumentError, "Color #{color} is not supported. Allowed colors are #{COLOR_CODES.keys.join(', ')}" end paint_with_code(string, color_code) end
paint_with_code(string, color_code)
click to toggle source
# File lib/fasterer/painter.rb, line 16 def self.paint_with_code(string, color_code) "\e[#{color_code}m#{string}\e[0m" end