Module: Quantity::CalculationSupport

Includes:
Quantifiable
Included in:
OperationInfo, Quantity, QuantityInfo
Defined in:
lib/unitmanager/quantity.rb

Instance Method Summary collapse

Methods included from Quantifiable

#quantifiable?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/unitmanager/quantity.rb', line 12

def method_missing(name, value)
  if supported_operation? name
    return perform_operation(value, name)
  else
    super.method_missing(name, value)
  end
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
25
# File 'lib/unitmanager/quantity.rb', line 20

def == (other)
  return false if other == nil
  return false unless other.kind_of?(self.class)
 
  value == other.value && unit == other.unit
end

#coerce(other) ⇒ Object



27
28
29
# File 'lib/unitmanager/quantity.rb', line 27

def coerce(other)
  [QuantityInfo.new(other, nil), self]
end