6 March 2008
The Units Pipe Dream...

Much of what’s driven my off-off-hours development over the last year is the architecture, design and coding of a Units Framework for Ruby. While there are a few out there, this one is different - predicated on a NumericWithUnits, units are added to Numerics transparently. They act exactly like Numerics without units, but assert their types when appropriate and handle conversions automatically, such as:

5.inches + 3.feet 41 inches
55.miles_per_hour.feet_second 80.666666667 ft / s
seconds_per_week 604800

To use them you just include the framework and everything just works. Go grab them for free at rubygems.

I wrote about the development as I went along, and humbly submit it for your reading pleasure.

This is just the first part of the development, however - only scalar units. When I need them, I’m going to add formulaic conversions (like temperature) and data-driven conversions (like currency).