class Runby::PaceRange
Represents a range of paces, from fast to slow.
Public Class Methods
new(fast, slow, distance_units = :km)
click to toggle source
# File lib/runby_pace/pace_range.rb, line 8 def initialize(fast, slow, distance_units = :km) if fast.is_a?(Pace) && slow.is_a?(Pace) @fast = fast @slow = slow else # Hopefully 'fast' and 'slow' are parseable as a RunbyTime distance = Distance.new distance_units, 1 @fast = Pace.new(fast, distance) @slow = Pace.new(slow, distance) end freeze end
Public Instance Methods
as_speed_range()
click to toggle source
# File lib/runby_pace/pace_range.rb, line 21 def as_speed_range SpeedRange.new @fast.as_speed, @slow.as_speed end
to_s(format: :short)
click to toggle source
# File lib/runby_pace/pace_range.rb, line 25 def to_s(format: :short) if @fast == @slow @fast.to_s(format: format) else @fast.to_s(format: format).sub(@fast.time.to_s, "#{@fast.time}-#{@slow.time}") end end