Eivind Eklund
1/4/2008 12:00:00 PM
On Jan 4, 2008 6:06 AM, Giles Bowkett <gilesb@gmail.com> wrote:
> Well, I'm writing a code generator, and I thought I was very close to
> finished, except I was basically doing this:
>
> generated_code = Generators.module_eval(&block)
>
> And that works great for tiny bits of code, it works at the statement
> level, but when I want to just collect up *all* the statements in a
> block, the whole thing kinds of goes south.
From the description you give, it sounds like you could just create a
new block that just calls a list of other blocks, and do ; separation?
Ie, if the line above is in a method called "foo(&block)", call it
with something like
foo do
my_blocks.collect { |block| block.call + ";" }
end
Probably I'm not understanding your requirements, just thought I'd air
it in case it is this simple.
Eivind.