Ruby 1.9.2 Reference Manual > All Libraries > Builtin Library > class Float > to_r

instance method Float#to_r

to_r -> Rational

自身を Rational に変換します。

例:

0.5.to_r      # => (1/2)