From: Joel VanderWerf Date: 2002-11-12T05:30:46+09:00 Subject: Re: Creating Proc from String? Austin Ziegler wrote: > I'm looking at extending a program that I've written to allow > arbitrary Ruby to be executed from within it. Basically, the > arbitrary Ruby will be executed ONLY in the context of something > like: > > a = IO.readlines(current_file) > a.each custom_block > > custom_block will be built from a string: > > { |line| > > } > > How would I do this? If I can get this figured out, then I'll worry > about how I get it working under exerb later (: Something like this maybe? irb(main):002:0> s = "x + 1" "x + 1" irb(main):003:0> pr = eval "proc {|x| #{s} }" # irb(main):004:0> pr[3] 4