Module: Precision
Class Method Summary collapse
-
.included ⇒ Object
call_seq: included.
Instance Method Summary collapse
-
#prec(klass) ⇒ Object
Converts self into an instance of klass.
-
#prec_f ⇒ Float
Returns a
Float
converted from num. -
#prec_i ⇒ Integer
Returns an
Integer
converted from num.
Class Method Details
.included ⇒ Object
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_f ⇒ Float
Returns a Float
converted from num. It is equivalent to prec(Float)
.
|
# File 'prec.c'
static VALUE
prec_prec_f(x)
VALUE x;
{
VALUE klass = rb_cFloat;
return rb_funcall(x, prc_pr, 1, klass);
}
|
#prec_i ⇒ Integer
Returns an Integer
converted from num. It is equivalent to prec(Integer)
.
|
# File 'prec.c'
static VALUE
prec_prec_i(x)
VALUE x;
{
VALUE klass = rb_cInteger;
return rb_funcall(x, prc_pr, 1, klass);
}
|