Skip to content

Instantly share code, notes, and snippets.

@fdelacruz
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save fdelacruz/ae798d16b42c9767858b to your computer and use it in GitHub Desktop.

Select an option

Save fdelacruz/ae798d16b42c9767858b to your computer and use it in GitHub Desktop.
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