A Ruby Gem for Measurements
Measurements and coversions library for Ruby
This package handles the basic units of measure:
The emphasis is on:
Internally, values are stored in SI units, with the exception of temperature:
new: accepts the S.I. unit as a parameter:
height = M9t::Distance.new(1.75)
to_f: returns the decimal value(s):
height.to_f -> 1.75
other units:
there are class methods named after each known unit,
which take values in that unit
(actually, they are defined as needed):
marathon = M9t::Distance.miles(26.21875)
marathon.to_f -> 42194.988
to_s: returns a localized string with units:
I18n.locale = :it
puts M9t::Distance.new(3).to_s -> '3 metri'
Methods are available for conversion between any pair of units:
M9t::Distance.miles_to_meters(26.21875) -> 42194.988
Dual license: