Sha256: b2e822741537008765fa8db14126462877264ba750d5e49dbf765d6d215309ca

Contents?: true

Size: 1.05 KB

Versions: 11

Compression:

Stored size: 1.05 KB

Contents

module RunbyPace

  module RunTypes

    class DistanceRun < RunType
      attr_reader :slow_pace_data, :fast_pace_data

      def description
        'Distance Run'
      end

      def initialize
        @fast_pace_data = PaceData.new(GoldenPaces::fast[:'14:00'], GoldenPaces::fast[:'42:00'], 3.675)
        @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 2.175)
      end

      def pace(five_k_time, distance_units = :km)
        fast = @fast_pace_data.calc(five_k_time, distance_units)
        slow = @slow_pace_data.calc(five_k_time, distance_units)
        PaceRange.new(fast, slow)
      end

      class GoldenPaces
        def self.fast
          { '14:00': '03:44', '15:00': '03:58', '20:00': '05:09', '25:00': '06:18', '30:00': '07:24', '35:00': '08:29', '40:00': '09:33', '42:00': '09:58'}
        end
        def self.slow
          { '14:00': '04:17', '15:00': '04:33', '20:00': '05:53', '25:00': '07:09', '30:00': '08:23', '35:00': '09:33', '40:00': '10:42', '42:00': '11:10'}
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
runby_pace-0.2.68 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.67 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.66 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.65 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.64 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.63 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.62 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.61 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.60 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.59 lib/runby_pace/run_types/distance_run.rb
runby_pace-0.2.58 lib/runby_pace/run_types/distance_run.rb