Closed zverok closed 8 years ago
Ideal requirements:
# Commons
# unit control
Measure[1, 'm'] + Measure[2, 'm'] # => Measure[3 m]
Measure[1, 'm'] + Measure[2, 's'] # => ConversionError
Measure[1, 'm'] * 3 # => Measure[3 m]
# symbolic computations
Measure[1, 'm'] / Measure[2, 's'] # => Measure[0.5 m/s]
Measure[1, 'm'] * Measure[3, 'm'] # => Measure[3 m²]
Measure[2, 'foo'] * Measure[3, 'foo'] / Measure[6, 'bar'] # => Measure[1 foo²/bar]
# pretty ouput (see above, all those "1 foo²/bar")
# Physical units
# unit conversion:
Measure[1, 'km'] + Measure[100, 'm'] # => Measure[1.1 km] or Measure[1100 m], don't know
Measure[1000, 'l'] / Measure[1, 'm'] # => Measure[1000 m²]
# ?interaction with Ruby's standard clasess:
Measure[1, 'hour'].since(Time.now) # => 1 hour in future
# ?but without core_ext'ing
Time.now + Measure[1, 'hour'] # => fails
Important: should work with any units (or be extendible, at least).
External candidates:
Currently it seems Unitwise is cool enough to try to extend it somehow?.. Or fork.
Partially implemented, see also #11 and #12
Measurement units, using countries as example: population returns
Reality::Measure[123400 people]
, which is inspectable and convertible, but checks unit on operations.