lib/runby_pace/pace.rb in runby_pace-0.6.143 vs lib/runby_pace/pace.rb in runby_pace-0.6.144

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + module Runby # Represents a pace consisting of a distance and a time in which that distance was covered class Pace include Comparable @@ -24,12 +26,11 @@ conversion_factor = target_distance / @distance Pace.new @time * conversion_factor, target_distance end def to_s(format: :short) - distance_s = @distance.to_s(format: format) leading_one_regex = /^1 ?/ - distance_s.gsub!(leading_one_regex, '') + distance_s = @distance.to_s(format: format).gsub(leading_one_regex, '') case format when :short then "#{time} p/#{distance_s}" when :long then "#{time} per #{distance_s}" end end