Demo entry 6708518

Listing 2.2

   

Submitted by anonymous on Feb 01, 2018 at 12:14
Language: Ruby. Code size: 298 Bytes.

class Gear
  attr_reader :chainring, :cog
  def initialize(chainring, cog)
    @chainring = chainring
    @cog       = cog
  end

  def ratio
    chainring / cog.to_f
  end
end

puts Gear.new(52, 11).ratio
# => 4.7272727272727275

puts Gear.new(30, 27).ratio
# => 1.1111111111111112

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).