diff options
| author | Tomoyuki Sahara <[email protected]> | 2014-03-04 12:45:11 +0900 |
|---|---|---|
| committer | Tomoyuki Sahara <[email protected]> | 2014-03-04 12:45:11 +0900 |
| commit | 4ad0896bdad6708ef0e45540ab53dcbfe5b94a55 (patch) | |
| tree | 980bc2481a3914d46677ad6f3d7e9842bacb7e68 /mrbgems/mruby-numeric-ext | |
| parent | 6b6277e2c6f24f66c021df345631e7d69ea13056 (diff) | |
| download | mruby-4ad0896bdad6708ef0e45540ab53dcbfe5b94a55.tar.gz mruby-4ad0896bdad6708ef0e45540ab53dcbfe5b94a55.zip | |
add Integer#div and Float#div.
Diffstat (limited to 'mrbgems/mruby-numeric-ext')
| -rw-r--r-- | mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb | 5 | ||||
| -rw-r--r-- | mrbgems/mruby-numeric-ext/test/numeric.rb | 8 |
2 files changed, 13 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..dfc6ba87c --- /dev/null +++ b/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb @@ -0,0 +1,5 @@ +module Integral + def div(other) + self.divmod(other)[0] + end +end diff --git a/mrbgems/mruby-numeric-ext/test/numeric.rb b/mrbgems/mruby-numeric-ext/test/numeric.rb index 1ca01648e..4d9e83113 100644 --- a/mrbgems/mruby-numeric-ext/test/numeric.rb +++ b/mrbgems/mruby-numeric-ext/test/numeric.rb @@ -13,3 +13,11 @@ assert('Integer#chr') do assert_raise(RangeError) { 256.chr } end end + +assert('Integer#div') do + assert_equal 52, 365.div(7) +end + +assert('Float#div') do + assert_float 52, 365.2425.div(7) +end |
