diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-26 11:14:40 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-04-26 11:14:40 +0000 |
commit | a90469602c82fe0fe607cc6f1c8f32b223db0394 (patch) | |
tree | f5e22a99f831016f4ea73911184a4dd57940978a /complex.c | |
parent | 76b33197e245c5ad070a3da427f096a82fccf898 (diff) | |
download | ruby-a90469602c82fe0fe607cc6f1c8f32b223db0394.tar.gz |
* complex.c, rational.c, lib/cmath.rb, lib/date.rb lib/date/delta*:
reverted r27484-27486. now official spec.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -1335,6 +1335,20 @@ nucomp_to_r(VALUE self) /* * call-seq: + * cmp.rationalize([eps]) -> rational + * + * Returns the value as a rational if possible. An optional argument + * eps is always ignored. + */ +static VALUE +nucomp_rationalize(int argc, VALUE *argv, VALUE self) +{ + rb_scan_args(argc, argv, "01", NULL); + return nucomp_to_r(self); +} + +/* + * call-seq: * nil.to_c -> (0+0i) * * Returns zero as a complex. @@ -1923,6 +1937,7 @@ Init_Complex(void) rb_define_method(rb_cComplex, "to_i", nucomp_to_i, 0); rb_define_method(rb_cComplex, "to_f", nucomp_to_f, 0); rb_define_method(rb_cComplex, "to_r", nucomp_to_r, 0); + rb_define_method(rb_cComplex, "rationalize", nucomp_rationalize, -1); rb_define_method(rb_cNilClass, "to_c", nilclass_to_c, 0); rb_define_method(rb_cNumeric, "to_c", numeric_to_c, 0); |