RichUnits is a very easy to use unit system for the Ruby programming language. It is essentially the same system popularized by Ruby on Rails.
Rich Units is a straight-forward units system based-on the original time units work by Rich Kilmer (circa 2002-2004). Rich Units extends core Ruby with conveneice methods for dealing with measures. The methods work by converting those measures to a low common denominator; for instance all durations are stored in seconds.
Rich Units provides essentially the same unit system used by Ruby on Rails*. But Rich Units seeks to imporve upon this code, and provides a superset of functionality, partly derived from the Ruby Facets distribution of the same libraries. Ultimately Rich Units intent is to provide a better system than either of these large projects can provide, by virture of a dedicated development track.
*with the present exception of the timezone extensions (coming soon).
Primarily Rich Units extends Numeric. Here are some basic examples:
require 'rich_units' 4.days.hence #=> Tue Apr 01 08:04:17 -0400 2008 4.hours.ago #=> Thu Mar 27 22:03:33 -0400 2008 10.bytes #=> 80
Rich Units also extends Time.
require 'rich_units' Time.now #=> Fri Mar 28 08:10:40 -0400 2008 Time.now.years_hence(4) #=> Wed Mar 28 08:10:47 -0400 2012
Installing the RubyGem is of course straight forward.
$ sudo gem install rich_units
Manual site_ruby installation is provided via Ruby Setup.
$ tar -xvzf rich_units-0.4.0.tgz $ cd rich_units-0.4.0 $ sudo setup.rb all
The project is hosted on GitHub at
Contributor Repository Access
To pull the 'richunits' repository anonymously, use:
git clone git://github.com/rubyworks/richunits.git
Otherwise create a fork.
Master Developer Repository Access
Developers, you can git commit access if you submit a good patch.
Only project developers have access to the main repository. Please contact transfire at gmail.com if you'd like to join the development team.