diff options
| author | Ukrainskiy Sergey <[email protected]> | 2018-09-22 16:53:56 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-05-15 16:57:21 +0900 |
| commit | fa45cc42726720b89732bf43d1bf433970007c89 (patch) | |
| tree | bc411f6dd7507c54c0880f45401b59bdde653d7c /mrbgems/mruby-rational/mrblib | |
| parent | d67d2ae8e88b93536e71dfa41a90721ce351da7c (diff) | |
| download | mruby-fa45cc42726720b89732bf43d1bf433970007c89.tar.gz mruby-fa45cc42726720b89732bf43d1bf433970007c89.zip | |
Fix dependencies
Diffstat (limited to 'mrbgems/mruby-rational/mrblib')
| -rw-r--r-- | mrbgems/mruby-rational/mrblib/rational.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/mrbgems/mruby-rational/mrblib/rational.rb b/mrbgems/mruby-rational/mrblib/rational.rb index ffadd55eb..7d5b87362 100644 --- a/mrbgems/mruby-rational/mrblib/rational.rb +++ b/mrbgems/mruby-rational/mrblib/rational.rb @@ -10,6 +10,18 @@ class Rational < Numeric "(#{to_s})" end + def to_f + @numerator.to_f / @denominator.to_f + end + + def to_i + to_f.to_i + end + + def to_r + self + end + def to_s "#{numerator}/#{denominator}" end |
