Created
October 5, 2012 14:59
-
-
Save rbrooks/3840315 to your computer and use it in GitHub Desktop.
Convert Decimal Aspect Ratio to Rational in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 4:3 | |
1.333.to_r.rationalize(Rational('0.001')) | |
# => (4/3) | |
# 16:9 | |
1.778.to_r.rationalize(Rational('0.001')) | |
# => (16/9) | |
# Common PAR: | |
1.212.to_r.rationalize(Rational('0.001')) | |
# => (40/33) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment