Improving on Sandi Metz's Gear Class from POODR - SaturnCI - Continuous Integration for Ruby on Rails

03-Apr-2026 288
Chapter 2 of Sandi Metz's Practical Object-Oriented Design: An Agile Primer Using Ruby (POODR), "Designing Classes with a Single Responsibility", opens by giving an example of a class which represents the concept of a bicycle gear. First, a bit about the concept itself: Gears work by changing how far the bicycle travels each time your feet complete one circle with the pedals. More specifically, your gear controls how many times the wheels rotate for each time the pedals rotate. In a small gear, your feet spin around several times to make the wheels rotate just once; in a big gear, each complete pedal rotation may cause the wheels to rotate multiple times. Here's the code Sandi gives to introduce the way a gear ratio is calculated.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle