Skip to content

Instantly share code, notes, and snippets.

@foucist
Created January 22, 2014 21:53
Show Gist options
  • Save foucist/bbdb3201c87de1acc099 to your computer and use it in GitHub Desktop.
Save foucist/bbdb3201c87de1acc099 to your computer and use it in GitHub Desktop.
poodr way
class Gear
attr_reader :chainring, :cog, :wheel
def initialize(chainring, cog, rim, tire)
@chainring = chainring
@cog = cog
@wheel = Wheel.new(rim, tire)
end
def ratio
chainring / cog.to_f
end
def gear_inches
ratio * wheel.diameter
end
Wheel = Struct.new(:rim, :tire) do
def diameter
rim + (tire * 2)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment