Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby library to convert from meters to miles from yards to fathoms from teaspoons to quarts and whatever else you could possibly want
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
tests
.gitignore
Rakefile
Readme.textile
alchemist.gemspec

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

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

And many more checkout lib/alchemist.rb for the rest

Something went wrong with that request. Please try again.