a

Ruby code posted
created at 07 May 22:29

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
    ratio*(rim+(tire*2))
  end
end

Gear.new(52, 11, 26, 1.5).gear_inches #=> 137.09..
Gear.new(52, 11)).ratio #=> error
383 Bytes in 8 ms with coderay