Last active
August 29, 2015 14:04
-
-
Save fdelacruz/ae798d16b42c9767858b to your computer and use it in GitHub Desktop.
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
| class Gear | |
| attr_reader :chainring, :cog, :rim, :tire | |
| def initialize(chainring, cog, rim, tire) | |
| @chainring = chainring | |
| @cog = cog | |
| @rim = rim | |
| @tire = tire | |
| end | |
| def ratio | |
| chainring / cog.to_f | |
| end | |
| def gear_inches | |
| # tire goes around rim twice for diameter | |
| ratio * (rim + (tire * 2)) | |
| end | |
| end | |
| puts Gear.new(52, 11, 26, 1.5).gear_inches | |
| # => 137.090909090909 | |
| puts Gear.new(52, 11, 24, 1.25).gear_inches | |
| # => 125.272727272727 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment