methods(...)
public
Returns a list of the names of methods
publicly accessible in obj. This will include all the methods accessible in obj’s
ancestors.
class Klass
def kMethod()
end
end
k = Klass.new
k.methods[0..9]
"class", "instance_variable_set",
"methods", "extend", "__send__", "instance_eval"]
k.methods.length
Show source
/*
* call-seq:
* obj.methods => array
*
* Returns a list of the names of methods publicly accessible in
* <i>obj</i>. This will include all the methods accessible in
* <i>obj</i>'s ancestors.
*
* class Klass
* def kMethod()
* end
* end
* k = Klass.new
* k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?",
* "class", "instance_variable_set",
* "methods", "extend", "__send__", "instance_eval"]
* k.methods.length #=> 42
*/
static VALUE
rb_obj_methods(argc, argv, obj)
int argc;
VALUE *argv;
VALUE obj;
{
retry:
if (argc == 0) {
VALUE args[1];
args[0] = Qtrue;
return rb_class_instance_methods(1, args, CLASS_OF(obj));
}
else {
VALUE recur;
rb_scan_args(argc, argv, "1", &recur);
if (RTEST(recur)) {
argc = 0;
goto retry;
}
return rb_obj_singleton_methods(argc, argv, obj);
}
}