pub unsafe extern "C" fn mrb_define_method(
mrb: *mut mrb_state,
cla: *mut RClass,
name: *const c_char,
func: mrb_func_t,
aspec: mrb_aspec,
)
Expand description
Defines a global function in ruby.
If you’re creating a gem it may look something like this
Example:
mrb_value example_method(mrb_state* mrb, mrb_value self)
{
puts("Executing example command!");
return self;
}
void mrb_example_gem_init(mrb_state* mrb)
{
mrb_define_method(mrb, mrb->kernel_module, "example_method", example_method, MRB_ARGS_NONE());
}
@param mrb The MRuby state reference. @param cla The class pointer where the method will be defined. @param name The name of the method being defined. @param func The function pointer to the method definition. @param aspec The method parameters declaration.