*(a)
public
Returns the product of this value and a.
Examples:
r = Rational(3,4)
r * 2
r * 4
r * 0.5
r * Rational(1,2)
Show source
def * (a)
if a.kind_of?(Rational)
num = @numerator * a.numerator
den = @denominator * a.denominator
Rational(num, den)
elsif a.kind_of?(Integer)
self * Rational.new!(a, 1)
elsif a.kind_of?(Float)
Float(self) * a
else
x, y = a.coerce(self)
x * y
end
end