Giter Club home page Giter Club logo

vanunits's Introduction

VanUnits

Description

VanUnits is a sophisticated SI units system. It also includes currency units and a large set of scientific constants.

Usage

Here are some examples of using the units system.

reqiure 'van/units'

include Van::Units

1.bit/s + 8.bytes/s
(1.bit/s).to(byte/s)
1.mile.to(feet)
1.acre.to(yd**2)
1.acre.to(sq_yd)
1.gallon.to(self.L)
1.lb.to(kg)
1.m.s.to(m.s)
1.sq_mi.to(km**2)
1.mile.to(km)

Van::Units is namespace for all unit related classes. Mixing this in has the additional effect of making Units.with_unit_converter available without the Units. prefix, as well as the shortcuts for creating Units (see Van::Units#method_missing).

Constants

Also included are a large assortment of real world contants. These come in two varieties, typeless and typed via units.rb. (PLEASE NOTE: The typed variety is not yet complete).

Constants are also provided in both mks (m kg s) and in cgs (cm g s) format.

require 'van/units/constants/mks'
require 'van/units/constants/cgs'

include Van::Units::Constants

MKS::SPEED_OF_LIGHT              #=> 2.99792458e8 m/s
CGS::SPEED_OF_LIGHT              #=> 2.99792458e10 cm/s

Big thanks to Daniel Carrera and Brian Gough for their original work on Math::Constants from which these numbers derive.

Authors/Contributors

  • Peter Vanbroekhoven

  • Thomas Sawyer

  • Daniel Carrera

  • Brian Gough

License

Copyright 2006, 2007 Peter Vanbroekhoven, Thomas Sawyer

Stick is distributed under the terms of the MIT license.

vanunits's People

Contributors

trans avatar

Stargazers

Gerald Bauer avatar Terra Metta avatar Peter Vanbroekhoven avatar Matt Scilipoti avatar

Watchers

 avatar Peter Vanbroekhoven avatar James Cloos avatar  avatar

vanunits's Issues

Stack Level Deep Error on most operations

Trying to use van/units on ruby 1.9.2 doing most operations i get a SystemStackError for stack level too deep. if i do '1.mile' in console i get a response but doing 'x = 1.mile' causes the error also. this is happening at lib/van/units/base.rb:847.

ruby-1.9.2-p136 :001 > require 'van/units'
=> true
ruby-1.9.2-p136 :002 > include Van::Units
=> Object
ruby-1.9.2-p136 :003 > 1.mile
=> 1 mile
ruby-1.9.2-p136 :004 > x = 1.mile
/Users/context/.rvm/gems/ruby-1.9.2-p136/gems/vanunits-1.5.0/lib/van/units/base.rb:847: stack level too deep (SystemStackError)
/Users/context/.rvm/gems/ruby-1.9.2-p136/gems/vanunits-1.5.0/lib/van/units/base.rb:847: stack level too deep (SystemStackError)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.