Class: Rational::compatible
Instance Method Summary collapse
-
#marshal_load(a) ⇒ Object
private
:nodoc:.
Instance Method Details
#marshal_load(a) ⇒ Object (private)
:nodoc:
1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 |
# File 'rational.c', line 1859
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;
}
|