module Colorate
Constants
- BOLD_BEGIN
- COLORS
- DECORATION_END
- OVERALL_END
- UNDERLINE_BEGIN
- VERSION
Public Class Methods
defaults()
click to toggle source
# File lib/colorate.rb, line 18 def self.defaults { bold: false, underline: false } end
method_missing(method, *args, &block)
click to toggle source
# File lib/colorate.rb, line 5 def self.method_missing(method, *args, &block) raise ArgumentError, 'Color not supported' unless COLORS.keys.include?(method) output_string = args[0] options = args[1] || {} options = defaults.merge(options) output_string = BOLD_BEGIN + output_string + DECORATION_END if options[:bold] output_string = UNDERLINE_BEGIN + output_string + DECORATION_END if options[:underline] COLORS[method.to_sym] + output_string + OVERALL_END end