lib/runby_pace/pace.rb in runby_pace-0.6.140 vs lib/runby_pace/pace.rb in runby_pace-0.6.141
- old
+ new
@@ -97,22 +97,20 @@
end
# @param [Pace, RunbyTime] other
def -(other)
if other.is_a?(Pace)
- raise 'Pace arithmetic with different units is not currently supported' unless @distance == other.distance
- Pace.new(@time - other.time, @distance)
+ Pace.new(@time - other.convert_to(@distance).time, @distance)
elsif other.is_a?(RunbyTime)
Pace.new(@time - other, @distance)
end
end
# @param [Pace, RunbyTime] other
def +(other)
if other.is_a?(Pace)
- raise 'Pace arithmetic with different units is not currently supported' unless @distance == other.distance
- Pace.new(@time + other.time, @distance)
+ Pace.new(@time + other.convert_to(@distance).time, @distance)
elsif other.is_a?(RunbyTime)
Pace.new(@time + other, @distance)
end
end
@@ -120,11 +118,11 @@
time = Runby::RunbyTime.new(time)
if time.total_minutes.zero? || @distance.multiplier.zero?
return Runby::Distance.new(@distance.uom, 0)
end
divisor = @time.total_minutes / time.total_minutes / @distance.multiplier
- distance_units_traveled = Runby::Distance.new(@distance.uom, 1 / divisor)
- distance_units_traveled
+ distance_covered = Runby::Distance.new(@distance.uom, 1 / divisor)
+ distance_covered
end
private
def init_from_clone(other_pace)