Method: Quantify::Unit::Base#is_alternative_for?
- Defined in:
- lib/quantify/unit/base_unit.rb
#is_alternative_for?(other) ⇒ Boolean
Determine if another unit is an alternative unit for self, i.e. do the two units represent the same physical quantity. This is established by compraing their dimensions attributes. E.g.
Unit.metre.is_alternative_for? Unit.foot #=> true
Unit.metre.is_alternative_for? Unit.gram #=> false
Unit.metre.is_alternative_for? Unit.metre #=> true
397 398 399 |
# File 'lib/quantify/unit/base_unit.rb', line 397 def is_alternative_for?(other) other.dimensions == @dimensions end |