Project

auom

0.01
No commit activity in last 3 years
No release in over 3 years
Algebra (with) Units Of Measurement
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.1.21

Runtime

~> 0.0.9
 Project Readme

AUOM Algebra (for) Units of Measurement

Build Status Dependency Status Code Climate

This is another unit system for ruby. It was created since I was not confident about the existing ones.

Features:

  • No unit conversions
  • No core patches (Especially does not require mathn!)
  • Dependency free.
  • Functional implementation style.
  • No magic coercion from number like strings to numbers.
  • Will never loose precision (Uses rational as scalar internally)
  • Allows namespacing of unit systems via subclass.
  • Well tested (100% mutation coverage via mutant)

The default set of predefined units is minimal as this library should be used in an application specific subclass. Override: AUOM::Unit.units

Installation

Install the gem auom via your preferred method.

Examples

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

Credits

Room for your name!

Contributing

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with Rakefile or version (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2014 Markus Schirp

See LICENSE for details