<=>(p1)
public
Comparison—Returns -1 if mod includes other_mod, 0
if mod is the same as other_mod, and +1 if mod
is included by other_mod or if
mod has no relationship with other_mod. Returns
nil if other_mod is not a module.
Show source
/*
* call-seq:
* mod <=> other_mod => -1, 0, +1, or nil
*
* Comparison---Returns -1 if <i>mod</i> includes <i>other_mod</i>, 0 if
* <i>mod</i> is the same as <i>other_mod</i>, and +1 if <i>mod</i> is
* included by <i>other_mod</i> or if <i>mod</i> has no relationship with
* <i>other_mod</i>. Returns <code>nil</code> if <i>other_mod</i> is
* not a module.
*/
static VALUE
rb_mod_cmp(mod, arg)
VALUE mod, arg;
{
VALUE cmp;
if (mod == arg) return INT2FIX(0);
switch (TYPE(arg)) {
case T_MODULE:
case T_CLASS:
break;
default:
return Qnil;
}
cmp = rb_class_inherited_p(mod, arg);
if (NIL_P(cmp)) return Qnil;
if (cmp) {
return INT2FIX(-1);
}
return INT2FIX(1);
}