B
Ben Bleything
Hi all,
As part of my IRB shell history hack (shameless plug[1]), I need to be
able to access the caller's binding. Essentially, I need to be able to
do this:
def irb_eval( lines, scope )
eval(lines.join("\n"), scope)
end
irb_eval( ['a = :foo', 'b = :bar'], binding )
... but without explicitly passing the binding. The goal is this:
irb_eval( ['a = :foo', 'b = :bar'] )
puts a
=> :foo
puts b
=> :bar
Is this even possible? As it is, the eval happens inside of irb_eval's
scope (I'm assuming... wherever it happens, I can't see the results when
it's done) which puts a cramp in my plans for world domination via cute
IRB hacks.
Help?
Thanks,
Ben
[1]: http://blog.bleything.net/articles/2006/10/21/shell-style-history-for-irb
As part of my IRB shell history hack (shameless plug[1]), I need to be
able to access the caller's binding. Essentially, I need to be able to
do this:
def irb_eval( lines, scope )
eval(lines.join("\n"), scope)
end
irb_eval( ['a = :foo', 'b = :bar'], binding )
... but without explicitly passing the binding. The goal is this:
irb_eval( ['a = :foo', 'b = :bar'] )
puts a
=> :foo
puts b
=> :bar
Is this even possible? As it is, the eval happens inside of irb_eval's
scope (I'm assuming... wherever it happens, I can't see the results when
it's done) which puts a cramp in my plans for world domination via cute
IRB hacks.
Help?
Thanks,
Ben
[1]: http://blog.bleything.net/articles/2006/10/21/shell-style-history-for-irb