Module: Precision

Included in:
Fixnum, Float, Integer
Defined in:
prec.c

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.includedObject

call_seq:

included

When the Precision module is mixed-in to a class, this included method is used to add our default induced_from implementation to the host class.



# File 'prec.c'

static VALUE
prec_included(module, include)
VALUE module, include;
{
switch (TYPE(include)) {
  case T_CLASS:
  case T_MODULE:
   break;
  default:
   Check_Type(include, T_CLASS);
   break;
}

Instance Method Details

#prec(klass) ⇒ Object

Converts self into an instance of klass. By default, prec invokes

klass.induced_from(num)

and returns its value. So, if klass.induced_from doesn't return an instance of klass, it will be necessary to reimplement prec.



# File 'prec.c'

static VALUE
prec_prec(x, klass)
    VALUE x, klass;
{
    return rb_funcall(klass, prc_if, 1, x);
}

#prec_fFloat

Returns a Float converted from num. It is equivalent to prec(Float).

Returns:



# File 'prec.c'

static VALUE
prec_prec_f(x)
    VALUE x;
{
    VALUE klass = rb_cFloat;

    return rb_funcall(x, prc_pr, 1, klass);
}

#prec_iInteger

Returns an Integer converted from num. It is equivalent to prec(Integer).

Returns:



# File 'prec.c'

static VALUE
prec_prec_i(x)
    VALUE x;
{
    VALUE klass = rb_cInteger;

    return rb_funcall(x, prc_pr, 1, klass);
}