Ruby port.

Here's my contribution of the ruby port. It is tested.