Add `Numeric#{finite?,infinite?}`; CRuby2.4
MODIFY
src/numeric.c
src/numeric.c
@@ -1254,6 +1254,20 @@ num_cmp(mrb_state *mrb, mrb_value self)
}
}
+static mrb_value
+num_finite_p(mrb_state *mrb, mrb_value self)
+{
+ mrb_get_args(mrb, "");
+ return mrb_true_value();
+}
+
+static mrb_value
+num_infinite_p(mrb_state *mrb, mrb_value self)
+{
+ mrb_get_args(mrb, "");
+ return mrb_false_value();
+}
+
/* 15.2.9.3.1 */
/*
* call-seq:
@@ -1284,6 +1298,8 @@ mrb_init_numeric(mrb_state *mrb)
mrb_define_method(mrb, numeric, "/", num_div, MRB_ARGS_REQ(1)); /* 15.2.8.3.4 */
mrb_define_method(mrb, numeric, "quo", num_div, MRB_ARGS_REQ(1)); /* 15.2.7.4.5 (x) */
mrb_define_method(mrb, numeric, "<=>", num_cmp, MRB_ARGS_REQ(1)); /* 15.2.9.3.6 */
+ mrb_define_method(mrb, numeric, "finite?", num_finite_p, MRB_ARGS_NONE());
+ mrb_define_method(mrb, numeric, "infinite?",num_infinite_p, MRB_ARGS_NONE());
/* Integer Class */
integer = mrb_define_class(mrb, "Integer", numeric); /* 15.2.8 */

Add `Numeric#{finite?,infinite?}`; CRuby2.4