summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-rational/mrblib/rational.rb
blob: ebe6829b015385f9294902cb6d3d5f55433322a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Rational < Numeric
  def inspect
    "(#{to_s})"
  end

  def to_s
    "#{numerator}/#{denominator}"
  end
end

class Numeric
  def to_r
    Rational(self, 1)
  end
end