Method: Quantify::Unit::Base#alternatives

Defined in:
lib/quantify/unit/base_unit.rb

#alternatives(by = nil) ⇒ Object

List the alternative units for self, i.e. the other units which share the same dimensions.

The list can be returned containing the alternative unit names, symbols or JScience labels by providing the required format as a symbolized argument.

If no format is provide, the full unit objects for all alternative units are returned within the array



411
412
413
414
415
# File 'lib/quantify/unit/base_unit.rb', line 411

def alternatives(by=nil)
  @dimensions.units(nil).reject do |unit|
    unit.is_equivalent_to?(self) || !unit.acts_as_alternative_unit
  end.map(&by).to_a
end