Every repository with this icon (
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
History.txt | ||
| |
LICENSE | ||
| |
Manifest.txt | ||
| |
README.textile | ||
| |
Rakefile | ||
| |
bin/ | ||
| |
lib/ | ||
| |
spec/ |
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)









