Refactoring exercises in Ruby