Return input as a partial fraction
Non-string input can lead to surprising results:

p (5/2).to_r #=&gt; (2/1), integer division performed first
p (1.1).to_r #=&gt; (2476979795053773/2251799813685248),  float can not be represented in binary


The last case is prevented by:

p 1.1.to_s.to_r #=&gt; (11/10)


So I'd change rational = fraction.to_r to rational = fraction.to_s.to_r.  But the first case is only handled correctly if it is a string to begin with: 

p "5/2".to_r #=&gt; (5/2)


I don't think there is a remedy for that, except accepting string or float input input only.