public
Description: A sweet Ruby measurement & converstion Library.
Homepage: http://daniel.collectiveidea.com/blog/2008/12/2/measurement-the-voodoo-library
Clone URL: git://github.com/collectiveidea/measurement.git
Click here to lend your support to: measurement and make a donation at www.pledgie.com !
brandon (author)
Mon Dec 01 20:26:29 -0800 2008
commit  ca48225a2f8cf11d72285033f23dc7a3d17268dd
tree    26a7206837951ea9649726a65395bc43f096e4ca
parent  acf8a8a4f26e0b125ab89782cf3ba3ff3aef7110
name age message
file History.txt Tue Sep 18 12:32:19 -0700 2007 All sorts of changes. Added prefixes; refactor... [Daniel Morrison]
file LICENSE Loading commit data...
file Manifest.txt Tue Sep 18 12:32:19 -0700 2007 All sorts of changes. Added prefixes; refactor... [Daniel Morrison]
file README.textile
file Rakefile
directory bin/ Sat Jul 28 07:59:40 -0700 2007 Empty gem, per hoe. [Daniel Morrison]
directory lib/
directory spec/
README.textile

measurement

A sweet Ruby measurement & converstion Library.

by Daniel Morrison, Collective Idea

Introduction

Measurement is a library I wrote ages ago, in large part to play with metaprogramming.

But its cool. All of the measurements and conversions are in yaml files, stored in lib/measurements. This lets me have fun with SI prefixes and such. Ideally these files would be a separate project, to be used by other languages, but that’s for another day.

What can it do?

Conversions.

<pre> > include Measurement::Length > Inch.new(12).to_centimeters => #<Measurement::Length::Centimeter:0x173c2b4 @units=30.48> </pre>

<pre> > include Measurement::Volume > Milliliter.new(100).to_teaspoons => #<Measurement::Volume::Teaspoon:0x1720e88 @units=45.0> </pre>

Check the yaml files to see what’s available, but note that SI prefixes (mega-, kilo-, yotta-, etc.) are applied magically, as are base2 prefixes for data.

What’s next?

Dunno, have ideas? Send me a message via github. I’m reviving the project after over a year, so its time to have some fun.

Some of my plans:

  • More units (please add!)
  • uh, tests.
  • Namespaced units (Volume::Beer::Barrel vs. Volume::Oil::Barrel)
  • Allow parents to be SI-derived (you can base a new unit on Meter, but not Kilometer)