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

instance method Rational#==

self == other -> bool

数値として等しいか判定します。

[PARAM] other:
比較対象の数値
[RETURN]
self と other が等しい場合 true を返します。 そうでなければ false を返します。

例:

Rational(2, 3)  == Rational(2, 3)   # => true
Rational(5)     == 5                # => true
Rational(0)     == 0.0              # => true
Rational(1, 3)  == 0.33             # => false
Rational(1, 2)  == '1/2'            # => false