runby_pace 0.6.94 → 0.6.97
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/runby_pace/golden_pace_set.rb +48 -0
- data/lib/runby_pace/pace_calculator.rb +3 -3
- data/lib/runby_pace/run_types/distance_run.rb +4 -4
- data/lib/runby_pace/run_types/easy_run.rb +4 -4
- data/lib/runby_pace/run_types/find_divisor.rb +5 -7
- data/lib/runby_pace/run_types/long_run.rb +4 -4
- data/lib/runby_pace/run_types/tempo_run.rb +4 -4
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTRjNzMyZmIwMThhMWViYjIyODYyYzAwMTQ5MjU5OTRjYmYwZDRmNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWEwZTc3MzBkMjMwMDUyMjlkOWQ1OTI1ODk2MTdkY2ZmNTczMmNlMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmE2ZDQ5NDAwYzFiMTFkNDA0OTlmNDI4NjE0OThiZDA5MDY1MWQzNWE2YjJl
|
10
|
+
YmYzYTYxZmZiNDNhODM4Nzg0ZjI0ZjFmNmVjYTNhYjUxM2IxYjhkOTQyOGQw
|
11
|
+
OGUxYmUxN2M5ZDkyNzE4ZTJkNWNmYzhjZGY1NTI0OWU5MTYxNTM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmVjMTU4Y2JjNWUzMGE4MzNiOGMwMjFlYzMzNzZhODI2MzI1Y2RjNmM0ZWNm
|
14
|
+
OTVlMTk2YTY5NjI2OTlkNzM2MDcxNjNhZWNmNDA4YTk0N2QxZDRmZDBlYmU3
|
15
|
+
ZDAyNjg4ZGY4OTg2YjgwMmFiZjhmMWY3NmUxMjc2MjkxNzc3YmY=
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Runby
|
2
|
+
|
3
|
+
# Maps a set of 5K race times with their pre-calculated pace recommendations.
|
4
|
+
# This is useful in testing as well as defining the fastest and slowest supported 5K times.
|
5
|
+
# GoldenPaceSet could conceivably be used to pre-compute a large number of recommended paces,
|
6
|
+
# thus reducing runtime CPU overhead.
|
7
|
+
class GoldenPaceSet
|
8
|
+
include Enumerable
|
9
|
+
|
10
|
+
attr_reader :paces
|
11
|
+
|
12
|
+
# The fastest 5K time supported by RunbyPace
|
13
|
+
@@FASTEST_5K = :'14:00'
|
14
|
+
|
15
|
+
# The slowest 5K time supported by RunbyPace
|
16
|
+
@@SLOWEST_5K = :'42:00'
|
17
|
+
|
18
|
+
# @param [Hash] paces_hash is a hash mapping 5K time symbols to times, represented as strings.
|
19
|
+
# An example paces_hash is {'14:00':'4:00', '15:00':'4:55'}
|
20
|
+
def initialize(paces_hash)
|
21
|
+
@paces = {}
|
22
|
+
paces_hash.each { |five_k_time, recommended_pace| @paces[five_k_time.to_sym] = Pace.new(recommended_pace) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(&block)
|
26
|
+
@paces.each do |h, v|
|
27
|
+
block.call(h, v)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns first/fastest recommended pace in the set
|
32
|
+
def first
|
33
|
+
@paces[@@FASTEST_5K]
|
34
|
+
end
|
35
|
+
alias :fastest :first
|
36
|
+
|
37
|
+
# Return the last/slowest recommended pace in the set
|
38
|
+
def last
|
39
|
+
@paces[@@SLOWEST_5K]
|
40
|
+
end
|
41
|
+
alias :slowest :last
|
42
|
+
|
43
|
+
# Creates and returns a new GoldenPaceSet with only two entries
|
44
|
+
def self.new_from_endpoints(fastest, slowest)
|
45
|
+
GoldenPaceSet.new({@@FASTEST_5K => fastest, @@SLOWEST_5K => slowest})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -25,9 +25,9 @@ module Runby
|
|
25
25
|
# until it matches that of the data. (See #curve_minutes)
|
26
26
|
attr_reader :midpoint_radius_divisor
|
27
27
|
|
28
|
-
def initialize(
|
29
|
-
@fastest_pace_km =
|
30
|
-
@slowest_pace_km =
|
28
|
+
def initialize(golden_pace_set, midpoint_radius_divisor)
|
29
|
+
@fastest_pace_km = golden_pace_set.fastest
|
30
|
+
@slowest_pace_km = golden_pace_set.slowest
|
31
31
|
@midpoint_radius_divisor = midpoint_radius_divisor
|
32
32
|
end
|
33
33
|
|
@@ -10,8 +10,8 @@ module Runby
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast
|
14
|
-
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow
|
13
|
+
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast, 3.675)
|
14
|
+
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow, 2.175)
|
15
15
|
end
|
16
16
|
|
17
17
|
def lookup_pace(five_k_time, distance_units = :km)
|
@@ -23,11 +23,11 @@ module Runby
|
|
23
23
|
# Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
|
24
24
|
class GoldenPaces
|
25
25
|
def self.fast
|
26
|
-
{ '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' }
|
26
|
+
GoldenPaceSet.new({ '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' })
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.slow
|
30
|
-
{ '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' }
|
30
|
+
GoldenPaceSet.new({ '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' })
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -9,8 +9,8 @@ module Runby
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast
|
13
|
-
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow
|
12
|
+
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast, 1.99)
|
13
|
+
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow, 1.35)
|
14
14
|
end
|
15
15
|
|
16
16
|
def lookup_pace(five_k_time, distance_units = :km)
|
@@ -22,11 +22,11 @@ module Runby
|
|
22
22
|
# Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
|
23
23
|
class GoldenPaces
|
24
24
|
def self.fast
|
25
|
-
{ '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:41', '42:00': '11:08' }
|
25
|
+
GoldenPaceSet.new({ '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:41', '42:00': '11:08' })
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.slow
|
29
|
-
{ '14:00': '05:01', '15:00': '05:20', '20:00': '06:51', '25:00': '08:17', '30:00': '09:38', '35:00': '10:56', '40:00': '12:10', '42:00': '12:39' }
|
29
|
+
GoldenPaceSet.new({ '14:00': '05:01', '15:00': '05:20', '20:00': '06:51', '25:00': '08:17', '30:00': '09:38', '35:00': '10:56', '40:00': '12:10', '42:00': '12:39' })
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -8,22 +8,20 @@ module Runby
|
|
8
8
|
# This method, #find_divisor, accepts a hash of "golden paces" for a run type along with
|
9
9
|
# the number of seconds of allowable deviation from the golden pace. Then it proceeds
|
10
10
|
# to brute force the divisor.
|
11
|
-
# @param [
|
11
|
+
# @param [GoldenPaceSet] golden_pace_set
|
12
12
|
# @param [String] allowable_deviation
|
13
13
|
# @return [decimal]
|
14
|
-
def self.find_divisor(
|
15
|
-
_, first_pace = golden_paces.first
|
16
|
-
last_pace = golden_paces[:'42:00']
|
14
|
+
def self.find_divisor(golden_pace_set, allowable_deviation = '00:01')
|
17
15
|
viable_divisors = []
|
18
16
|
|
19
17
|
(1.0..5.0).step(0.025) do |candidate_divisor|
|
20
18
|
viable_divisor = nil
|
21
19
|
|
22
|
-
|
20
|
+
golden_pace_set.each do |five_k, golden_pace|
|
23
21
|
five_k_time = Runby::RunbyTime.new(five_k.to_s)
|
24
|
-
pace_data = Runby::PaceCalculator.new(
|
22
|
+
pace_data = Runby::PaceCalculator.new(golden_pace_set, candidate_divisor)
|
25
23
|
calculated_pace = pace_data.calc(five_k_time)
|
26
|
-
unless calculated_pace.time.almost_equals?(golden_pace, allowable_deviation)
|
24
|
+
unless calculated_pace.time.almost_equals?(golden_pace.time, allowable_deviation)
|
27
25
|
viable_divisor = nil
|
28
26
|
break
|
29
27
|
end
|
@@ -10,8 +10,8 @@ module Runby
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def initialize
|
13
|
-
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast
|
14
|
-
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow
|
13
|
+
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast, 2.125)
|
14
|
+
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow, 1.55)
|
15
15
|
end
|
16
16
|
|
17
17
|
def lookup_pace(five_k_time, distance_units = :km)
|
@@ -23,11 +23,11 @@ module Runby
|
|
23
23
|
# Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
|
24
24
|
class GoldenPaces
|
25
25
|
def self.fast
|
26
|
-
{ '14:00': '04:00', '15:00': '04:16', '20:00': '05:31', '25:00': '06:44', '30:00': '07:54', '35:00': '09:01', '40:00': '10:07', '42:00': '10:32' }
|
26
|
+
GoldenPaceSet.new({ '14:00': '04:00', '15:00': '04:16', '20:00': '05:31', '25:00': '06:44', '30:00': '07:54', '35:00': '09:01', '40:00': '10:07', '42:00': '10:32' })
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.slow
|
30
|
-
{ '14:00': '04:39', '15:00': '04:57', '20:00': '06:22', '25:00': '07:43', '30:00': '09:00', '35:00': '10:15', '40:00': '11:26', '42:00': '11:53' }
|
30
|
+
GoldenPaceSet.new({ '14:00': '04:39', '15:00': '04:57', '20:00': '06:22', '25:00': '07:43', '30:00': '09:00', '35:00': '10:15', '40:00': '11:26', '42:00': '11:53' })
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -9,8 +9,8 @@ module Runby
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast
|
13
|
-
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow
|
12
|
+
@fast_pace_calculator = PaceCalculator.new(GoldenPaces.fast, 4.025)
|
13
|
+
@slow_pace_calculator = PaceCalculator.new(GoldenPaces.slow, 3.725)
|
14
14
|
end
|
15
15
|
|
16
16
|
def lookup_pace(five_k_time, distance_units = :km)
|
@@ -22,11 +22,11 @@ module Runby
|
|
22
22
|
# Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
|
23
23
|
class GoldenPaces
|
24
24
|
def self.fast
|
25
|
-
{ '14:00': '03:07', '15:00': '03:20', '20:00': '04:21', '25:00': '05:20', '30:00': '06:19', '35:00': '07:16', '40:00': '08:12', '42:00': '08:35' }
|
25
|
+
GoldenPaceSet.new({ '14:00': '03:07', '15:00': '03:20', '20:00': '04:21', '25:00': '05:20', '30:00': '06:19', '35:00': '07:16', '40:00': '08:12', '42:00': '08:35' })
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.slow
|
29
|
-
{ '14:00': '03:18', '15:00': '03:31', '20:00': '04:35', '25:00': '05:37', '30:00': '06:38', '35:00': '07:38', '40:00': '08:36', '42:00': '08:59' }
|
29
|
+
GoldenPaceSet.new({ '14:00': '03:18', '15:00': '03:31', '20:00': '04:35', '25:00': '05:37', '30:00': '06:38', '35:00': '07:38', '40:00': '08:36', '42:00': '08:59' })
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runby_pace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.97
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ty Walls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- lib/runby_pace.rb
|
76
76
|
- lib/runby_pace/distance.rb
|
77
77
|
- lib/runby_pace/distance_unit.rb
|
78
|
+
- lib/runby_pace/golden_pace_set.rb
|
78
79
|
- lib/runby_pace/pace.rb
|
79
80
|
- lib/runby_pace/pace_calculator.rb
|
80
81
|
- lib/runby_pace/pace_range.rb
|
@@ -99,7 +100,7 @@ homepage: https://github.com/tygerbytes/runby-pace
|
|
99
100
|
licenses:
|
100
101
|
- MIT
|
101
102
|
metadata:
|
102
|
-
commit-hash:
|
103
|
+
commit-hash: 5e1379080b4314c7009d6c63015cc05c607c3aa7
|
103
104
|
post_install_message:
|
104
105
|
rdoc_options: []
|
105
106
|
require_paths:
|