Module: Unite::Comparison

Extended by:
ActiveSupport::Concern
Includes:
Dimension::Integer
Included in:
Conversion
Defined in:
lib/unite/comparison.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Methods included from Dimension::Integer

#dimension_int, #property, #property_name

Instance Method Details

#==(other) ⇒ Object



27
28
29
# File 'lib/unite/comparison.rb', line 27

def == other
  self.compatible?(other) && self.convert_to(other).value == other.value
end

#compatible!(other) ⇒ Object



23
24
25
# File 'lib/unite/comparison.rb', line 23

def compatible! other
  compatible?(other) ? true : raise(IncompatibleError)
end

#compatible?(other) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/unite/comparison.rb', line 19

def compatible? other
  self.dimension_int == other.dimension_int
end

#compatible_unitsObject



31
32
33
# File 'lib/unite/comparison.rb', line 31

def compatible_units
  Lookup.compatible_units self.dimension_int
end