static public Method

Float.induced_from(p1)

Float.induced_from(obj)      float

Convert obj to a float.

Source Code

/*
* call-seq:
*   Float.induced_from(obj)    =>  float
*
* Convert <code>obj</code> to a float.
*/

static VALUE
rb_flo_induced_from(klass, x)
   VALUE klass, x;
{
   switch (TYPE(x)) {
   case T_FIXNUM:
   case T_BIGNUM:
      return rb_funcall(x, rb_intern("to_f"), 0);
   case T_FLOAT:
      return x;
   default:
      rb_raise(rb_eTypeError, "failed to convert %s into Float",
               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.