Should use `to_int` instead of `to_i`
authorksss <[email protected]>
Tue, 4 Apr 2017 02:10:34 +0000 (4 11:10 +0900)
committerksss <[email protected]>
Tue, 4 Apr 2017 02:19:43 +0000 (4 11:19 +0900)
For CRuby compatibility

src/pack.c

index 6a0075f..5a5b97b 100644 (file)
@@ -1018,11 +1018,7 @@ mrb_pack_pack(mrb_state *mrb, mrb_value ary)
 
       o = mrb_ary_ref(mrb, ary, aidx);
       if (type == PACK_TYPE_INTEGER) {
-        if (mrb_float_p(o)) {
-          o = mrb_funcall(mrb, o, "to_i", 0);
-        } else if (!mrb_fixnum_p(o)) {
-          mrb_raisef(mrb, E_TYPE_ERROR, "can't convert %S into Integer", mrb_class_path(mrb, mrb_obj_class(mrb, o)));
-        }
+        o = mrb_to_int(mrb, o);
       } else if (type == PACK_TYPE_FLOAT) {
         if (!mrb_float_p(o)) {
           o = mrb_funcall(mrb, o, "to_f", 0);