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.
Improving on Sandi Metz's Gear Class from POODR - SaturnCI - Continuous Integration for Ruby on Rails #ruby #rubydeveloper #rubyonrails #Improving #Sandi #Metz's #Class #POODR #SaturnCI #Continuous #Integration #Rails #class #integration https://rubyonrails.ba/link/improving-on-sandi-metz-s-gear-class-from-poodr-saturnci-continuous-integration-for-ruby-on-rails