Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Ruby on Rails plugin that adds conversion capabilities to numeric objects

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .yardopts
Octocat-spinner-32 Gemfile
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.markdown
Octocat-spinner-32 Rakefile
Octocat-spinner-32 conversions.gemspec


Converting units LIKE A BOSS (now based on the alchemist gem)


Having unit conversion 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?

You can even perform mathematic operations

10.kilometers + 1.mile # 11.609344 kilometers

You may also register your own units

Conversions.register(:distance, [:beard_second, :beard_seconds], 5.angstroms)

You can even compare different units

5.grams == 0.005.kilograms


gem install conversions


require 'conversions'   


If you're using rails, add to your Gemfile:

gem 'conversions'

Conversions has conversions for:


  • 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


  • grams or grammes
  • carats
  • ounces
  • pennyweights
  • pounds
  • troy_pounds or apothecary_pounds
  • slugs
  • assay_tons
  • metric_tons
  • tons or short_tons


  • 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!

Check out lib/conversions/default_table.rb for the rest

Collaboration cycle

Please contribute patches!


  1. Fork the emitter repository on GitHub.
  2. Write a test proving the existing implementation's inadequacy. Ensure that the test fails.
  3. Improve the code until your new test passes and commit your changes.
  4. Push your changes to your GitHub fork.
  5. Submit a pull request to us.


  1. Receive a pull request.
  2. Pull changes from forked repository.
  3. Ensure tests pass.
  4. Review changes
  5. Merge changes to master repository and publish.
Something went wrong with that request. Please try again.