Class: Rational::compatible
Instance Method Summary collapse
-
#marshal_load(a) ⇒ Object
private
:nodoc:.
Instance Method Details
#marshal_load(a) ⇒ Object (private)
:nodoc:
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 |
# File 'rational.c', line 1845
static VALUE
nurat_marshal_load(VALUE self, VALUE a)
{
VALUE num, den;
rb_check_frozen(self);
Check_Type(a, T_ARRAY);
if (RARRAY_LEN(a) != 2)
rb_raise(rb_eArgError, "marshaled rational must have an array whose length is 2 but %ld", RARRAY_LEN(a));
num = RARRAY_AREF(a, 0);
den = RARRAY_AREF(a, 1);
nurat_int_check(num);
nurat_int_check(den);
nurat_canonicalize(&num, &den);
rb_ivar_set(self, id_i_num, num);
rb_ivar_set(self, id_i_den, den);
return self;
}
|