lib/quantify/quantity.rb
# Conversion where self is a compound unit, and new unit is not an alternative
# to the whole compound but IS an alternative to one or more of the base units,
# e.g.,
#
#   Unit.kilowatt_hour.to :second           #=> 'kilowatt second'
#
Conversion where self is a compound unit, and new unit is not an alternative
to the whole compound but IS an alternative to one or more of the base units,
e.g..


Conversion where self is a compound unit and new unit is not an alternative to the whole compound but IS an alternative to one or more of the base units e . g ..
def convert_compound_unit_to_non_equivalent_unit!(new_unit)
      @unit.base_units.select do |base|
        base.unit.is_alternative_for? new_unit
      end.inject(self) do |quantity,base|
        factor = Unit.ratio(new_unit**base.index, base.unit**base.index)
        quantity.multiply!(factor).cancel_base_units!(base.unit)
      end
    end
def convert_compound_unit_to_non_equivalent_unit! ( new_unit ) @unit . base_units . select do | base | base . unit . is_alternative_for? new_unit end . inject ( self ) do | quantity , base | factor = Unit . ratio ( new_unit ** base . index , base . unit ** base . index ) quantity . multiply! ( factor ) . cancel_base_units! ( base . unit ) end end
Conversion where self is a compound unit, and new unit is not an alternative
to the whole compound but IS an alternative to one or more of the base units,
e.g.,
Conversion where self is a compound unit and new unit is not an alternative to the whole compound but IS an alternative to one or more of the base units e . g .
new_unit
<not_specific>