lib/runby_pace/pace.rb in runby_pace-0.6.102 vs lib/runby_pace/pace.rb in runby_pace-0.6.103
- old
+ new
@@ -12,11 +12,17 @@
@time = Runby::RunbyTime.new(time_or_pace)
@distance = Runby::Distance.new(distance)
end
end
- def to_s
- "#{time} per #{distance.pluralized_uom}"
+ def to_s(format = :long)
+ distance_s = @distance.to_s(format)
+ leading_zero_regex = /^1 ?/
+ distance_s.gsub!(leading_zero_regex, '')
+ case format
+ when :short then "#{time} p/#{distance_s}"
+ when :long then "#{time} per #{distance_s}"
+ end
end
def <=>(other)
if other.is_a? Pace
return nil unless @distance == other.distance