• Stars
    star
    154
  • Rank 242,095 (Top 5 %)
  • Language
    Ruby
  • Created almost 15 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A scientific conversion library.

Alchemist

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!

8.miles.to.meters

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

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

require 'alchemist/geospatial'
1.mile.geospatial.to.degree == 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)

Installation

gem install alchemist

Setup

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

Rails

Setup

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)

License

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

More Repositories

1

oath

Oath is rails authentication made simple. Previously known as Monban
Ruby
372
star
2

ArkhamHorror

An unofficial rules-compliant browser based version of Arkham Horror: The Card Game. Not produced, endorsed, or supported by, or affiliated with Fantasy Flight Games.
Haskell
118
star
3

excelsior

Makefile
37
star
4

dagon

The programming language of the elder gods.
Ruby
29
star
5

reconstructing-ruby

Ruby implementation for the blog post series http://www.halogenandtoast.com/reconstructing-ruby-an-introduction/
Bison
19
star
6

oath-generators

Rails generators for the oath authentication library
Ruby
16
star
7

vim

vim
Vim Script
8
star
8

intermediate_workshop

Ruby
7
star
9

nhk-reader-haskell

Haskell implementation of my NHK Reader
Haskell
7
star
10

griddle

GridFS made simple.
Ruby
7
star
11

MarvelChampions

A rules-compliant browser based version of Marvel Champions.
Haskell
5
star
12

terminal_minesweeper

Minesweeper in the terminal
Ruby
4
star
13

intro_workshop

Ruby
4
star
14

kitsune

Ruby
3
star
15

mirin

A tiny redirection server in Spock backed by MySQL.
Haskell
3
star
16

game

A Game
C++
3
star
17

presentable

Simple presenters for rails.
Ruby
3
star
18

timelord

Parse dates out of strings
Ruby
3
star
19

AdventOfCode2020

Haskell
3
star
20

holdem

Texas Hold'em API Competition
Ruby
2
star
21

tengu

A RSpec-like testing framework.
Ruby
2
star
22

intermediate

intermediate
Ruby
2
star
23

Robots-Tower-Defense

Node.js game for 2011 Node Knockout competition
JavaScript
2
star
24

dotfiles

Delectable dotfiles!
Vim Script
2
star
25

codenames

A rails version of the codenames board game
Ruby
2
star
26

LightsOut

Lights out implementation in Haskell
Haskell
2
star
27

Pinchlist

A project
Ruby
2
star
28

halogenandtoast.github.io

resume
HTML
1
star
29

haskell-cabal-new-buildpack

Shell
1
star
30

count_von_count

Ruby
1
star
31

irxml

Gem for dealing with irxml's api
Ruby
1
star
32

babushka-deps

Personal Deps for Babushka
1
star
33

scrub

Ruby
1
star
34

squawkr

Haskell
1
star
35

intermediate_workshop_2_11_13

intermediate_workshop_2_11_13
Ruby
1
star
36

bonsai

The bonsai programming language
C
1
star
37

boardgamenight

The board game night app.
Ruby
1
star
38

memori

memoriapp.com
Ruby
1
star
39

AdventOfCode2021

Haskell
1
star
40

dagon-c

A C implementation of the dagon language
C
1
star
41

tagged

Ruby
1
star
42

boardy

A slack bot for finding boardgamegeek games
Haskell
1
star
43

intermediate_rails

intermediate_rails
Ruby
1
star
44

terminal

terminal settings
Shell
1
star
45

opengl_experiments

opengl_expriments
C++
1
star
46

opengl_project

C++
1
star