diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-05-18 18:57:47 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-05-18 18:57:47 +0900 |
| commit | 1cdb3ec93c09629dd24cab8a5e8f66ae6d26bf60 (patch) | |
| tree | 7c65c56fe44b08e8346615b0ff6a72648006126b /mrbgems/mruby-rational | |
| parent | ed70e81264df4ce0650abfe86e72148aa7d422ba (diff) | |
| parent | 6c9c189e4b9b5a340e220b333bc5f975fdb65adc (diff) | |
| download | mruby-1cdb3ec93c09629dd24cab8a5e8f66ae6d26bf60.tar.gz mruby-1cdb3ec93c09629dd24cab8a5e8f66ae6d26bf60.zip | |
Merge pull request #4448 from shuujii/move-Object-Rational-Complex-to-Kernel
Move `Object#(Rational|Complex)` to `Kernel`
Diffstat (limited to 'mrbgems/mruby-rational')
| -rw-r--r-- | mrbgems/mruby-rational/mrblib/rational.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/mrbgems/mruby-rational/mrblib/rational.rb b/mrbgems/mruby-rational/mrblib/rational.rb index 870c12242..19c6da9e7 100644 --- a/mrbgems/mruby-rational/mrblib/rational.rb +++ b/mrbgems/mruby-rational/mrblib/rational.rb @@ -75,11 +75,13 @@ class Numeric end end -def Rational(numerator = 0, denominator = 1) - a = numerator - b = denominator - a, b = b, a % b until b == 0 - Rational._new(numerator.div(a), denominator.div(a)) +module Kernel + def Rational(numerator = 0, denominator = 1) + a = numerator + b = denominator + a, b = b, a % b until b == 0 + Rational._new(numerator.div(a), denominator.div(a)) + end end [:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].each do |op| |
