Skip to content
A scientific conversion library.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec Refactor using Module subclass Aug 9, 2017
.gitignore Store unit name Mar 1, 2015
Gemfile.lock Added Coverage. Dec 4, 2013 Updated readme to reflect use_si usage Dec 26, 2016
alchemist.gemspec Change description and summary Mar 1, 2015


Build Status Code Climate

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

meters = 8 * 1609.344

You could add comments

meters = 8 * 1609.344 # converting miles to meters

But why not have this!

You can even perform mathematical operations

10.kilometers + 1.mile # 11.609344 kilometers

Handling bytes now works according to the JEDEC memory standard == 1024.0

Converting distance of arc length on Earth to an (approximate) corresponding spherical geometry angle can be done with

require 'alchemist/geospatial' == 0.014457066992474555

To switch to the IEC memory standard, force SI units with

Alchemist.config.use_si = true

To see all the units alchemist has built in conversion for, check out the units file

You may also register your own units

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


gem install alchemist


In order for methods like 1.meter to work, you'll either need to setup Alchemist yourself:

Alchemist.setup # This will load every category of measurement

if you only want to use one category for conversions you can load it individually:

Alchemist.setup('distance') # This will load only distance



It is suggested that you add your Alchemist.setup call to config/initializers/alchemist.rb and then restart your rails server.

Rails Warning

Rails adds some methods like bytes to Numeric so it's highly recommended that instead of trying to call bytes on a numeric, you should use the measure method:

Alchemist.measure(10, :bytes)


Alchemist is licensed under the MIT license as specified in the gemspec

You can’t perform that action at this time.