diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-30 09:48:25 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-30 09:48:25 +0000 |
commit | 60712bdc10947b53508ff6f5ab064e5462776968 (patch) | |
tree | 20444740e2fce4c4f6dad0269f610b73cca646a6 /numeric.c | |
parent | 82baf3973f6a691038c0d65d4f282a8a2485dc42 (diff) | |
download | ruby-60712bdc10947b53508ff6f5ab064e5462776968.tar.gz |
Define Integer#<= instead of Bignum#<=.
* numeric.c (int_le): Define Integer#<=.
* bignum.c (rb_big_le): Don't define Bignum#<=.
Renamed from big_le.
* internal.h (rb_big_le): Declared.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -3906,11 +3906,12 @@ fix_lt(VALUE x, VALUE y) } /* + * Document-method: Integer#<= * Document-method: Fixnum#<= * call-seq: - * fix <= real -> true or false + * int <= real -> true or false * - * Returns +true+ if the value of +fix+ is less than or equal to that of + * Returns +true+ if the value of +int+ is less than or equal to that of * +real+. */ @@ -3933,6 +3934,18 @@ fix_le(VALUE x, VALUE y) } } +static VALUE +int_le(VALUE x, VALUE y) +{ + if (FIXNUM_P(x)) { + return fix_le(x, y); + } + else if (RB_TYPE_P(x, T_BIGNUM)) { + return rb_big_le(x, y); + } + return Qnil; +} + /* * Document-method: Integer#~ * call-seq: @@ -4885,6 +4898,8 @@ Init_Numeric(void) rb_define_method(rb_cInteger, "abs", int_abs, 0); rb_define_method(rb_cInteger, "magnitude", int_abs, 0); + rb_define_method(rb_cInteger, "<=", int_le, 1); + rb_define_method(rb_cFixnum, "==", fix_equal, 1); rb_define_method(rb_cFixnum, "===", fix_equal, 1); rb_define_method(rb_cFixnum, ">", fix_gt, 1); |