What is the ruby C API equivalent of this

Hello friends,

I’m having a hard time implementing the equivalent of this in the ruby
C API:

module M
module_function
def run(&block)
module_eval(&block)
end
end

How is the &block operation implemented in the C API? im looking for
something to convert a proc to a
block. i’ve scanned many of the .c files and have found nothing.
Anyone have any ideas?

cheers

John

On Aug 9, 2008, at 5:43 AM, [email protected] wrote:

Hello friends,

Hi!

How is the &block operation implemented in the C API? im looking for
something to convert a proc to a
block. i’ve scanned many of the .c files and have found nothing.
Anyone have any ideas?

static VALUE
m_run( VALUE module )
{
if (rb_block_given_p()) {
rb_mod_module_eval(0, 0, module);
}
return Qnil;
}

VALUE module = rb_define_module(“M”);
rb_define_module_function( module, “run”, m_run, 0 );

Blessings,
TwP