Codes from the book "Programming Collective Intelligence by Toby Segaran", parsed from python to ruby