Skip to content

hugoxrosa/PhysicsUnits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

PhysicsUnits
------------

This project was created to convert from diferent units of measurement,
in ruby using a nice notation.

The notation is on form: object.from.in_to.
Where 'from' is the origin unit and 'to' is the unit to converting to.

To use just make a require:
require 'physicsunit.rb'

The module 'PhysicsUnit' is included in 'Numeric' class

Some examples, using irb:

irb(main):001:0> require './physicsunits'

irb(main):002:0> 1.in.in_mm		# inches to milimeters
=> 25.4

irb(main):003:0> 80.km.in_mi		# kilometers to miles
=> 49.7096953789867

irb(main):004:0> 32.cal.in_J		# calories in joules
=> 133.9776

irb(main):005:0> 2000.kcal.in_J		# kilocalories in joules
=> 8373600.0

irb(main):006:0> 72.hp.in_kW		# horse power in kilowatts
=> 52.95591

irb(main):007:0> 1.3.GW.in_hp		# gigawatts in horse power
=> 1767508.10249508

irb(main):008:0> 1.atm.in_psi		# atmosphers in pound per inches
=> 14.6959494003922

irb(main):009:0> 1.atm.in_mmHg		# atmosphers in milimeters of Hg
=> 760.0

irb(main):010:0> water = 1.atm.in_mH2O	# atmosphers in meters of water
=> 10.2768871818387

irb(main):011:0> water.m.in_ft		# meters to feet
=> 33.7168214627253

irb(main):012:0> 

About

Allow conversion between units of measurements.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published