code from the book pragmatic programming - programming ruby 1.9 & 2.0