Algebra with units of measurement.
This is another unit system for ruby.
It was created since I was not confident about the existing ones.
Features:
The default set of predefined units is minimal as this library should be used in an application
specific subclass. Override: AUOM::Unit.units
Install the gem auom
via your preferred method.
require 'auom'
include AUOM
u = Unit.new(1, :meter) # <AUOM::Unit @scalar=1 meter>
u * 100 # <AUOM::Unit @scalar=100 meter>
u / Unit.new(10, :meter) # <AUOM::Unit @scalar=0.1>
u / Unit.new(10, [ :meter, :meter ]) # <AUOM::Unit @scaler=0.1 1/meter>
u * Unit.new(10, :meter) # <AUOM::Unit @scalar=10 meter^2>
u * Unit.new(1, :euro) # <AUOM::Unit @scalar=1 euro*meter>
u - Unit.new(1, :meter) # <AUOM::Unit @scalar=0 meter>
u + Unit.new(1, :meter) # <AUOM::Unit @scalar=2 meter>
u + Unit.new(1, :euro) # raises error about incompatible units
Room for your name!
Copyright © 2014 Markus Schirp
See LICENSE
for details