Method: Weight#-

Defined in:
lib/weight.rb

#-(other) ⇒ Weight

Substract operation

Parameters:

  • The other weight to substract to the current one

Returns:

  • The substraction of the two weights

Raises:

  • When the argument passed is not a Weight



80
81
82
83
# File 'lib/weight.rb', line 80

def -(other)
  raise TypeError, 'You can only substract weights' unless other.is_a?(Weight)
  self.class.new(value - other_value(other), unit)
end