From: Gary Wright Date: 2007-05-18T08:58:22+09:00 Subject: Re: Coopting String interpolation On May 16, 2007, at 9:20 PM, aurelianito wrote: > We all know the #{} operator for String interpolation. > It's used like this: > > name="Aure" > greeting="hi, #{name}" > > and greeting evaluates to "hi, Aure". But I would like to change it. > Is there a pure Ruby way to force "hi, #{name}" to evaluate to "hi, > AURE" (get the uppercase of the original interpolated String). I just released my Jig package that might be helpful to you. require 'rubygems' require 'jig' # Create a named 'gap' that upcases everything upcase = Jig::Gap.new(:name) { |x| x.upcase } # Create a jig consisting of a string, and the customize 'upcasing' gap. greeting = Jig["hi, ", upcase] # Fill the gap with data to generate a new jig. # puts calls Jig#to_s to convert the new jig to a string puts greeting % { :name => "Aure" } # => hi, AURE puts greeting % { :name => "Gary" } # => hi, GARY