This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Fri Oct 23 06:45:06 -0700 2009 | |
| |
Rakefile | Wed Nov 18 07:26:32 -0800 2009 | |
| |
Readme.textile | Wed Nov 11 11:23:02 -0800 2009 | |
| |
alchemist.gemspec | Wed Nov 18 07:26:32 -0800 2009 | |
| |
lib/ | Wed Nov 18 07:26:32 -0800 2009 | |
| |
test/ | Mon Nov 16 18:06:46 -0800 2009 |
Readme.textile
Alchemist
Doing conversions for you so you don’t have to google them and making code more readable.
Having code that looks like this is meaningless
miles = 8 * 1609.344
You could add comments
miles = 8 * 1609.344 # converting meters to miles
But why not have this!
8.meters.to.miles
You can even perform mathematical operations
10.kilometers + 1.mile # 11.609344 kilometers
Handling bytes now works according to the JEDEC memory standard
1.kb.to.b.to_f == 1024.0
To switch to the IEC memory standard, force SI units with
Alchemist::use_si = true
You may also register your own units
Alchemist.register(:distance, [:beard_second, :beard_seconds], 5.angstroms)
Thanks to simonmenke you can now do comparisons without having to convert to floats like so:
5.grams == 0.005.kilograms
Installation
gem sources -a http://gemcutter.org sudo gem install alchemist
Usage
require 'rubygems' require 'alchemist'
Or if you’re using rails
config.gem 'alchemist', :source => 'http://gemcutter.org'
Alchemist has conversions for:
Distance
- metres or meters
- fermis
- microns
- chains
- inches
- microinches
- mils
- rods
- leagues
- feet
- yards
- miles
- astronomical_units
- light_years
- parsecs
- nautical_miles
- admirality_miles
- fathoms
- cable_lengths
- angstroms
- picas
- printer_picas
- points
- printer_points
Mass
- grams or grammes
- carats
- ounces
- pennyweights
- pounds
- troy_pounds or apothecary_pounds
- slugs
- assay_tons
- metric_tons
- tons or short_tons
Volume
- litres or liters
- barrels
- bushels
- cubic_meters
- cups
- imperial_fluid_ounces
- fluid_ounces
- imperial_gallons
- gallons
- imperial_gills
- gills
- pints
- liquid_pints
- quarts
- liquid_quarts
- tablespoons
- teaspoons







