aboutsummaryrefslogtreecommitdiffstats
path: root/numeric.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 10:42:06 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-30 10:42:06 +0000
commit8733177dd07bf4dca25253af02dfafd3cf629874 (patch)
treeacafb9036da975fb54cb09070d8b05831ddd7a49 /numeric.c
parenta0501dd5ea64289d0e7c6100b1ce609395c6483c (diff)
downloadruby-8733177dd07bf4dca25253af02dfafd3cf629874.tar.gz
Define Integer#> instead of Bignum#>.
* numeric.c (int_gt): Define Integer#>. * bignum.c (rb_big_gt): Don't define Bignum#>. Renamed from big_gt. * internal.h (rb_big_gt): Declared. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/numeric.c b/numeric.c
index 9fe4379552..5c3bc2912f 100644
--- a/numeric.c
+++ b/numeric.c
@@ -3826,11 +3826,12 @@ int_cmp(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 greater than that of +real+.
+ * Returns +true+ if the value of +int+ is greater than that of +real+.
*/
static VALUE
@@ -3851,6 +3852,18 @@ fix_gt(VALUE x, VALUE y)
}
}
+static VALUE
+int_gt(VALUE x, VALUE y)
+{
+ if (FIXNUM_P(x)) {
+ return fix_gt(x, y);
+ }
+ else if (RB_TYPE_P(x, T_BIGNUM)) {
+ return rb_big_gt(x, y);
+ }
+ return Qnil;
+}
+
/*
* Document-method: Integer#>=
* Document-method: Fixnum#>=
@@ -4924,6 +4937,7 @@ 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_gt, 1);
rb_define_method(rb_cInteger, ">=", int_ge, 1);
rb_define_method(rb_cInteger, "<", int_lt, 1);
rb_define_method(rb_cInteger, "<=", int_le, 1);