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 ⇒ Object
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'
/*
* 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.
*/
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;
}
rb_define_singleton_method(include, "induced_from", prec_induced_from, 1);
return module;
}
|
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'
/*
* call-seq:
* num.prec(klass) => a_klass
*
* Converts _self_ into an instance of _klass_. By default,
* +prec+ invokes
*
* klass.induced_from(num)
*
* and returns its value. So, if <code>klass.induced_from</code>
* doesn't return an instance of _klass_, it will be necessary
* to reimplement +prec+.
*/
static VALUE
prec_prec(x, klass)
VALUE x, klass;
{
return rb_funcall(klass, prc_if, 1, x);
}
|
#prec_f ⇒ Object
Returns a Float
converted from num. It is equivalent to prec(Float)
.
|
# File 'prec.c'
/*
* call-seq:
* num.prec_f => Float
*
* Returns a +Float+ converted from _num_. It is equivalent
* to <code>prec(Float)</code>.
*/
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'
/*
* call-seq:
* num.prec_i => Integer
*
* Returns an +Integer+ converted from _num_. It is equivalent
* to <code>prec(Integer)</code>.
*/
static VALUE
prec_prec_i(x)
VALUE x;
{
VALUE klass = rb_cInteger;
return rb_funcall(x, prc_pr, 1, klass);
}
|