Module | Units |
In: |
lib/facets/more/units.rb
|
This is a very extensive SI units system.
Here are some examples of usage.
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) 1.usd.to(twd)
The 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 Units#method_missing).
Executes the block with the current Converter changed to the given Converter. This allows to temporarily change the Converter used by default.
Example:
with_unit_converter(:uk) { puts 1.cwt.to(lb) # => 112.0 lb } with_unit_converter(:us) { puts 1.cwt.to(lb) # => 100.0 lb }
See also Converter.current.