Expression Interpolation from input "template string"?

Peter,

irb(main):001:0* s = 'This is #{a} test.'
=> "This is \#{a} test."
irb(main):002:0> a = 'one'
=> "one"
irb(main):003:0> eval("\"#{s}\"")
=> "This is one test."
...
irb(main):004:0> eval("%{#{s}}")
=> "This is one test."

How/Where did you reference the knowledge for using
%{} and how to embed interpolation (Is this nested
interpolation?)

    The %{} syntax is just another form of general delimited input, like
%q{} and %Q{}. In other words, all of these are equivalent:

'a'
"a"
%q{a}
%{a}
%<a>
%_a_

    These are described in the Pickaxe book, as well as many other Ruby
books.

    As to embedded/nested interpolation, it's the #eval() method that's
doing all the magic here. In the first example, the parameter to
#eval() is the string:

'"This is #{a} test."'

    This string is executed as a Ruby statement, and its value is
returned. This would be the same thing as typing into irb:

"This is #{a} test."

    The second example just looks prettier to my eye, and makes the
parameter to #eval() the string:

'%{This is #{a} test.}'

    The %{} is just taking the place of the ugly \" stuff.

    I hope this helps.

    - Warren Brown