Ruby gem, color codes and string interpolation : I am trying to create a Ruby gem to colorize text. I am having hard time with string interpolation and color codes.
Say I want blue text

    puts "\e[34mThis is blue text.\e[0m"
That's the way I get it.
I am using the "define_method" metaprogramming technique to create multiple methods(one for every color). The methods are created just fine, but I keep the color code for each color in an array. I iterate over both the color array and the color code one, and I do this

    puts "\e#{code}m[#{self}\e[0m"
When I run it I get
"m[test" instead of the colorized text.
Any thoughts? If instead of #{code} I put the actual code, it works just fine, but that'd be like 20 ifs, one for each color and it won't be DRY.
Thank you.