Module: AUOM::Equalization

Included in:
Unit
Defined in:
lib/auom/equalization.rb

Overview

Equalization for auom units

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ true, false

Check for equivalent value and try to convert

Examples:


u = Unit.new(1, :meter)
u == u                   # => true
u == 1                   # => false
u == Unit.new(1, :meter) # => true

u = Unit.new(1)
u == 1                   # => true
u == Rational(1)         # => true
u == 1.0                 # => false

Parameters:

  • other (Object)

Returns:

  • (true)

    return true if is other is a unit and scalar and unit is the same after try of conversion.

  • (false)

    return false otherwise



29
30
31
# File 'lib/auom/equalization.rb', line 29

def ==(other)
  eql?(self.class.try_convert(other))
end