From f88e9f1dfc1f88f2a52e159d6ba818cf405706cc Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 26 Aug 2010 07:53:22 -0400 Subject: [PATCH] Removed method missing from color module. --- src/edgecase.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/edgecase.rb b/src/edgecase.rb index 3da9435..2718032 100644 --- a/src/edgecase.rb +++ b/src/edgecase.rb @@ -47,12 +47,18 @@ module EdgeCase module Color #shamelessly stolen from redgreen COLORS = { :clear => 0, :red => 31, :green => 32, :yellow => 33, :blue => 34, :magenta => 35, :cyan => 36 } - def self.method_missing(color_name, *args) - color(color_name) + args.first + color(:clear) - end - def self.color(color) - "\e[#{COLORS[color.to_sym]}m" - end + + COLORS.each do |color, value| + class_eval "def self.#{color}(string); colorize(string, #{value}); end" + end + + def self.colorize(string, color_value) + color(color_value) + string + color(COLORS[:clear]) + end + + def self.color(color_value) + "\e[#{color_value}m" + end end class Sensei