Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > rationalライブラリ > Rationalクラス > to_i

instance method Rational#to_i

truncate -> Integer
to_i -> Integer

0 から 自身までの整数で、自身にもっとも近い整数を返します。

例:

Rational(2, 3).to_i   # => 0
Rational(3).to_i      # => 3
Rational(98, 71).to_i # => 1
Rational(-30, 2).to_i # => -15

[SEE_ALSO] Rational#ceil, Rational#floor

class Rational