Hi, Rational currently doesn’t accept Rationals as

Numerator/Denominator. I wrote a patch for it and look for feedback.

Thanks.

def Rational(a, b = 1)

Rational.reduce(*Rational.normalize(a,b))

end

class Rational < Numeric

# normalizes numerator/denominator to non-rationals

def Rational.normalize(num,den)

if a.kind_of?(Rational) then

if b == 1 then

return [a.nominator, a.denominator]

elsif b.kind_of?(Rational) then

return [a.numerator*b.denominator, a.denominator*b.numerator]

else

return [a.numerator, a.denominator*b]
end
elsif b.kind_of?(Rational) then
if a == 1 then
return [b.denominator, b.nominator]
else
return [a*b.denominator, b.numerator]

end

else

return [a,b]

end

end

def Rational.new!(num, den = 1)

new(*Rational.normalize(a,b))

end

end