Meh, I felt like converting a private javascript exercise to ruby.