Sha256: 48d0c41030a5a8389dc50b31fc6d265e43661e55d68b9788c9efcf4cedb3e475

Contents?: true

Size: 606 Bytes

Versions: 2

Compression:

Stored size: 606 Bytes

Contents

require_relative 'runby_range'

module RunbyPace
  # Represents a range of speeds, from fast to slow.
  class SpeedRange < RunbyRange
    def initialize(fast, slow)
      raise 'Invalid speed values' unless fast.is_a?(Numeric) && slow.is_a?(Numeric)
      @fast = fast.round(2)
      @slow = slow.round(2)
    end

    # Create a new speed range from an existing pace range.
    def self.from_pace_range(pace_range)
      fast = RunbyPace::RunMath.convert_pace_to_speed pace_range.fast
      slow = RunbyPace::RunMath.convert_pace_to_speed pace_range.slow
      SpeedRange.new fast, slow
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
runby_pace-0.2.74 lib/runby_pace/speed_range.rb
runby_pace-0.2.73 lib/runby_pace/speed_range.rb