I'm working on a tiny code generation problem.
I like #dump because it puts things in readable form:
"\002\004\n" and so on.
I'm generating Ruby code from Ruby. I'm inserting some vars
and expressions in the strings:
name = "foo"
str = 'My value is #{' + name + '}' # Note the single quotes
However, when I do a dump of this, it marks the interpolated value
with a backslash (as a favor to me):
"My value is \#{foo}"
I want all of the other features of #dump, without the backslash
in front of interpolated values. How can I get that?
For now I'm just changing '\#{' to '#{' -- but what if my string
contains a real '\#{' someday (always a possibility in code
generation and metaprogramming)?
Thanks,
Hal