static public Method

Integer.induced_from(p1)

Integer.induced_from(obj)      fixnum, bignum

Convert obj to an Integer.

Source Code

/*
* call-seq:
*   Integer.induced_from(obj)    =>  fixnum, bignum
*
* Convert <code>obj</code> to an Integer.
*/

static VALUE
rb_int_induced_from(klass, x)
   VALUE klass, x;
{
   switch (TYPE(x)) {
   case T_FIXNUM:
   case T_BIGNUM:
      return x;
   case T_FLOAT:
      return rb_funcall(x, id_to_i, 0);
   default:
      rb_raise(rb_eTypeError, "failed to convert %s into Integer",
               rb_obj_classname(x));
   }
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.