Method: Quantify::Unit::Base#divide
- Defined in:
- lib/quantify/unit/base_unit.rb
#divide(other) ⇒ Object Also known as: /
Divide one unit by another. This results in the generation of a compound unit.
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).
459 460 461 462 463 464 465 466 467 468 469 |
# File 'lib/quantify/unit/base_unit.rb', line 459 def divide(other) = [] self.instance_of?(Unit::Compound) ? += @base_units : << self if other.instance_of? Unit::Compound += other.base_units.map { |base| base.index *= -1; base } else << CompoundBaseUnit.new(other,-1) end Unit::Compound.new(*) end |