Code from chapter 3 of Ruby in Action for codefellows