Sha256: 9cda65c86e135141b2fa6dd0e4ee38f2cf2722a6931260a3cc59b256bc29d81e
Contents?: true
Size: 941 Bytes
Versions: 6
Compression:
Stored size: 941 Bytes
Contents
require_relative 'runby_range' module Runby # Represents a range of paces, from fast to slow. class PaceRange < RunbyRange 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 end # Create a new pace range from an existing speed range. def self.from_speed_range(speed_range) fast = RunMath.convert_speed_to_pace speed_range.fast slow = RunMath.convert_speed_to_pace speed_range.slow PaceRange.new fast, slow end def to_s if @fast.time == @slow.time @fast.to_s else "#{@fast.time}-#{@slow.time} per #{@fast.distance.pluralized_uom}" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems