diff options
Diffstat (limited to 'mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb')
| -rw-r--r-- | mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb index dfc6ba87c..576605cb1 100644 --- a/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +++ b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb @@ -1,5 +1,21 @@ -module Integral - def div(other) - self.divmod(other)[0] +class Numeric + 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 |
