Rational Numbers for trees in ruby