lib/quantify/unit/base_unit.rb
# Raise a unit to a power. This results in the generation of a compound
# unit, e.g. m^3.
# 
# In the event that the new unit represents a known unit, the non-compound
# representation is returned (i.e. of the SI or NonSI class).
#
Raise a unit to a power. This results in the generation of a compound
unit, e.g. m^3.

In the event that the new unit represents a known unit, the non-compound
representation is returned .
Raise a unit to a power . This results in the generation of a compound unit e . g . m^3 . In the event that the new unit represents a known unit the non - compound representation is returned .
def pow(power)
        return nil if power == 0
        cloned_unit = self.clone
        return cloned_unit if power == 1
        if power > 0
          new_unit = self.clone
          (power - 1).times { new_unit *= cloned_unit }
        elsif power < 0
          new_unit = reciprocalize
          ((power.abs) - 1).times { new_unit /= cloned_unit }
        end
        return new_unit
      end
def pow ( power ) return nil if power == 0 cloned_unit = self . clone return cloned_unit if power == 1 if power > 0 new_unit = self . clone ( power - 1 ) . times { new_unit *= cloned_unit } elsif power < 0 new_unit = reciprocalize ( ( power . abs ) - 1 ) . times { new_unit /= cloned_unit } end return new_unit end
Raise a unit to a power.
Raise a unit to a power .
power
<not_specific>