From 3f5138a6ac9cdd4c3d52c386088d07df334fcadc Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 12 Mar 2024 23:30:36 +0900 Subject: [PATCH] mruby-numeric-ext: implement Numeric#integer? method --- mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb index ee205b85a..3f0c6dca1 100644 --- a/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +++ b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb @@ -76,6 +76,19 @@ class Numeric def nobits?(mask) (self & mask) == 0 end + + ## + # call-seq: + # num.integer? -> true or false + # + # Returns true if num is an Integer. + # + # 1.0.integer? #=> false + # 1.integer? #=> true + # + def integer? + false + end end class Integer @@ -96,4 +109,8 @@ class Integer def ceildiv(other) -div(-other) end + + def integer? + true + end end