Is it wrong that I was secretly hoping the answer was "I rewrote it in something that isn't ruby"?
That said, good writeup, even for a non-Rubyist, enjoyed seeing the process.
One thing that stuck out is how control flow via if/then/else is faster than via case (for more than 2 options) in Ruby. I always assumed the opposite, for any language.
[1] http://www.skorks.com/2009/08/how-a-ruby-case-statement-work... [2] http://www.daniellesucher.com/2013/07/ruby-case-versus-if/
Contracts are not needed and it obfuscates the error raising. Just use plain Ruby if you need to raise an exception. I'm will seriously quit using Ruby if someone makes me use contracts.
But it looks like a fun project to write. Nothing wrong with that.