lib/runby_pace/distance.rb in runby_pace-0.61.154 vs lib/runby_pace/distance.rb in runby_pace-0.61.155
- old
+ new
@@ -66,15 +66,16 @@
def to_s(format: :short)
formatted_multiplier = format('%g', @multiplier.round(2))
case format
when :short then "#{formatted_multiplier} #{@uom.to_s(format: format)}"
when :long then "#{formatted_multiplier} #{@uom.to_s(format: format, pluralize: (@multiplier > 1))}"
+ else raise "Invalid string format #{format}"
end
end
# @param [Distance, String] other
def <=>(other)
- raise "Cannot compare Runby::Distance to #{other.class}" unless [Distance, String].include? other.class
+ raise "Cannot compare Runby::Distance to #{other.class}(#{other})" unless [Distance, String].include? other.class
if other.is_a?(String)
return 0 if to_s == other || to_s(format: :long) == other
return self <=> Distance.try_parse(other)[:distance]
end
kilometers <=> other.kilometers