summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-numeric-ext/mrblib
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-numeric-ext/mrblib')
-rw-r--r--mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
new file mode 100644
index 000000000..f250538fe
--- /dev/null
+++ b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb
@@ -0,0 +1,25 @@
+module Integral
+ def div(other)
+ self.divmod(other)[0]
+ end
+
+ def zero?
+ self == 0
+ end
+
+ def nonzero?
+ if self == 0
+ nil
+ else
+ self
+ end
+ end
+
+ def positive?
+ self > 0
+ end
+
+ def negative?
+ self < 0
+ end
+end