If you are in the middle of some C code and you want to run an
arbitrary Ruby expression without writing a bunch of C, you can always
use the C version of
eval
. Suppose you have a collection of
objects that need to have a flag cleared.
rb_eval_string("anObject.each{|x| x.clearFlag }");
|
If you just want to call a particular method (which is cheaper than
eval
-ing an entire string) you can use
rb_funcall(receiver, method_id, argc, ...)
|
Full descriptions of these and other commonly used C functions begin
on page 186.