Class | Units::Value |
In: |
lib/facets/more/units.rb
|
Parent: | Numeric |
This class represents a Value with a numeric value and a Unit. The numeric value can be any Numeric, though it is not recommended to use Values.
A Value can be added to, subtracted from and multiplied with another value, though only when both Values are using the same Converter. While multiplication is always possible, adding or subtracting values with incompatible Units results in a TypeError. When two Units are compatible but not the same, the Value with the larger of the Units is converted to the smaller of the Units. For example adding 100 seconds and 1 minute, the latter is converted to 60 seconds because a second is smaller than a minute. The result is 160 seconds.