runby_pace 0.6.90 → 0.6.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/runby_pace/pace.rb +1 -0
- data/lib/runby_pace/pace_data.rb +9 -5
- data/lib/runby_pace/pace_range.rb +20 -5
- data/lib/runby_pace/run_types/find_divisor.rb +1 -1
- data/lib/runby_pace/speed_range.rb +3 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjdhNDYyNjQzZmE3ZTQzNDU3MTlhMmIzYWY0OTgxMWUwNmJlMTJlZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2IyYWI4MTNlMTVkNDdkOGM2NTI2YjljMzEyMzgzNjNlNmM4NzkyYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDg2MDRkMjAzN2MyY2ZhZjk2ODFjZjBlMGMxOGEyNjViNjM2YWFhOWM0Njcz
|
10
|
+
OTY5ODljYjY4NzUzMmI1MWViZWE5ZDg3MzUzNGE2MTNmZTI2MjdkYTY0Y2Vm
|
11
|
+
Yzg4MDM3MDAxMWE1NTk1YjQ2MGI4ZjczZTM5MWYxN2NiYWVmMDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzE0ZDFmNjM3NWRlMjQzNWNhZjIyMDJiNGEwZTU4ZGQzMWViNjhiM2U0NmFi
|
14
|
+
N2QwOGI5ODA1OGQ2ZmM1OTNkMDYyZTJkZWI2NWI4NTNhNjhjOGNlNTUwODFh
|
15
|
+
NTJiYjZjYTBlYjRkYjUwMGViYTMzZDhjMmMwN2FmZTBmZWQxZTU=
|
data/lib/runby_pace/pace.rb
CHANGED
@@ -2,6 +2,7 @@ module Runby
|
|
2
2
|
# Represents a pace consisting of a distance and a time in which that distance was covered
|
3
3
|
class Pace
|
4
4
|
attr_reader :time, :distance
|
5
|
+
|
5
6
|
def initialize(time, distance = '1K')
|
6
7
|
@time = Runby::RunbyTime.parse(time)
|
7
8
|
@distance = Runby::Distance.new(distance)
|
data/lib/runby_pace/pace_data.rb
CHANGED
@@ -26,14 +26,14 @@ module Runby
|
|
26
26
|
attr_reader :midpoint_radius_divisor
|
27
27
|
|
28
28
|
def initialize(fastest_pace_km, slowest_pace_km, midpoint_radius_divisor)
|
29
|
-
@fastest_pace_km =
|
30
|
-
@slowest_pace_km =
|
29
|
+
@fastest_pace_km = Pace.new(fastest_pace_km)
|
30
|
+
@slowest_pace_km = Pace.new(slowest_pace_km)
|
31
31
|
@midpoint_radius_divisor = midpoint_radius_divisor
|
32
32
|
end
|
33
33
|
|
34
34
|
# Calculate the slope of the line between the fastest and slowest paces
|
35
35
|
def slope
|
36
|
-
(@slowest_pace_km.total_minutes - @fastest_pace_km.total_minutes) / (DATA_POINTS_COUNT - 1)
|
36
|
+
(@slowest_pace_km.time.total_minutes - @fastest_pace_km.time.total_minutes) / (DATA_POINTS_COUNT - 1)
|
37
37
|
end
|
38
38
|
|
39
39
|
# Calculate the prescribed pace for the given 5K time
|
@@ -41,9 +41,13 @@ module Runby
|
|
41
41
|
five_k_time = Runby::RunbyTime.new five_k_time
|
42
42
|
distance_units = Runby::DistanceUnit.new distance_units
|
43
43
|
x2 = ((five_k_time.total_minutes * 2) - (MIDPOINT_X - 1)) - 1
|
44
|
-
minutes_per_km = slope * x2 + @fastest_pace_km.total_minutes + curve_minutes(x2)
|
44
|
+
minutes_per_km = slope * x2 + @fastest_pace_km.time.total_minutes + curve_minutes(x2)
|
45
45
|
minutes_per_unit = minutes_per_km * distance_units.conversion_factor
|
46
|
-
|
46
|
+
|
47
|
+
# TODO: Is there a way to clean up all of this "newing up"?
|
48
|
+
time = RunbyTime.from_minutes(minutes_per_unit)
|
49
|
+
distance = Distance.new distance_units, 1
|
50
|
+
Pace.new time, distance
|
47
51
|
end
|
48
52
|
|
49
53
|
private
|
@@ -3,16 +3,31 @@ require_relative 'runby_range'
|
|
3
3
|
module Runby
|
4
4
|
# Represents a range of paces, from fast to slow.
|
5
5
|
class PaceRange < RunbyRange
|
6
|
-
def initialize(fast, slow)
|
7
|
-
|
8
|
-
|
6
|
+
def initialize(fast, slow, distance_units = :km)
|
7
|
+
if fast.is_a?(Pace) && slow.is_a?(Pace)
|
8
|
+
@fast = fast
|
9
|
+
@slow = slow
|
10
|
+
else
|
11
|
+
# Hopefully 'fast' and 'slow' are parseable as a RunbyTime
|
12
|
+
distance = Distance.new distance_units, 1
|
13
|
+
@fast = Pace.new(fast, distance)
|
14
|
+
@slow = Pace.new(slow, distance)
|
15
|
+
end
|
9
16
|
end
|
10
17
|
|
11
18
|
# Create a new pace range from an existing speed range.
|
12
19
|
def self.from_speed_range(speed_range)
|
13
|
-
fast =
|
14
|
-
slow =
|
20
|
+
fast = RunMath.convert_speed_to_pace speed_range.fast
|
21
|
+
slow = RunMath.convert_speed_to_pace speed_range.slow
|
15
22
|
PaceRange.new fast, slow
|
16
23
|
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
if @fast.time == @slow.time
|
27
|
+
@fast.to_s
|
28
|
+
else
|
29
|
+
"#{@fast.time}-#{@slow.time} per #{@fast.distance.pluralized_uom}"
|
30
|
+
end
|
31
|
+
end
|
17
32
|
end
|
18
33
|
end
|
@@ -23,7 +23,7 @@ module Runby
|
|
23
23
|
five_k_time = Runby::RunbyTime.new(five_k.to_s)
|
24
24
|
pace_data = Runby::PaceData.new(first_pace, last_pace, candidate_divisor)
|
25
25
|
calculated_pace = pace_data.calc(five_k_time)
|
26
|
-
unless calculated_pace.almost_equals?(golden_pace, allowable_deviation)
|
26
|
+
unless calculated_pace.time.almost_equals?(golden_pace, allowable_deviation)
|
27
27
|
viable_divisor = nil
|
28
28
|
break
|
29
29
|
end
|
@@ -11,8 +11,9 @@ module Runby
|
|
11
11
|
|
12
12
|
# Create a new speed range from an existing pace range.
|
13
13
|
def self.from_pace_range(pace_range)
|
14
|
-
|
15
|
-
|
14
|
+
# TODO: We need a Speed class with Distance_units included
|
15
|
+
fast = Runby::RunMath.convert_pace_to_speed pace_range.fast.time
|
16
|
+
slow = Runby::RunMath.convert_pace_to_speed pace_range.slow.time
|
16
17
|
SpeedRange.new fast, slow
|
17
18
|
end
|
18
19
|
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.91
|
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-09-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,7 +99,7 @@ homepage: https://github.com/tygerbytes/runby-pace
|
|
99
99
|
licenses:
|
100
100
|
- MIT
|
101
101
|
metadata:
|
102
|
-
commit-hash:
|
102
|
+
commit-hash: bca3bf3dde2a647c39066155a2eaba08968521ce
|
103
103
|
post_install_message:
|
104
104
|
rdoc_options: []
|
105
105
|
require_paths:
|