runby_pace 0.2.74 → 0.2.75
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.rb +1 -1
- data/lib/runby_pace/pace_data.rb +6 -6
- data/lib/runby_pace/pace_range.rb +5 -5
- data/lib/runby_pace/pace_time.rb +1 -1
- data/lib/runby_pace/pace_units.rb +1 -1
- data/lib/runby_pace/run_math.rb +5 -5
- data/lib/runby_pace/run_type.rb +2 -2
- data/lib/runby_pace/run_types/all_run_types.template +1 -1
- data/lib/runby_pace/run_types/distance_run.rb +1 -1
- data/lib/runby_pace/run_types/easy_run.rb +1 -1
- data/lib/runby_pace/run_types/fast_tempo_run.rb +1 -1
- data/lib/runby_pace/run_types/find_divisor.rb +4 -4
- data/lib/runby_pace/run_types/long_run.rb +1 -1
- data/lib/runby_pace/run_types/slow_tempo_run.rb +1 -1
- data/lib/runby_pace/run_types/tempo_run.rb +1 -1
- data/lib/runby_pace/runby_range.rb +1 -1
- data/lib/runby_pace/speed_range.rb +3 -3
- data/lib/runby_pace/version.rb +1 -1
- data/runby_pace.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjBmOWNkMTQ5ZTI3YWMyYTIzZDQzNjY5ZWVmMjY5NDdmOWUzZGRiYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDE3YWI0NTZhMWJjOGFkNDk3MjNiMjNjNGRjZTYzNWU0ODM4OTBlNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjZlMGU3ZmNjY2UxNGE4YTQzMTNkZDU1NTFjYTdlYTI4ZmE1NTYxMTJmM2Jm
|
10
|
+
ZTY3ZjFkOTQ1MTBiMzA3ZWRmNWFhMWI0YmZmYTg4ZjIwMTYzN2M1N2I4NGJl
|
11
|
+
OWEwM2VkNmI5NDkyOTI1ZDdjZDI4MmM0NjgxZDk0Yjk1NDJhOWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTE2MjgyZmNkZmMzZTA4Njg5N2E4MmIyMzAxYmI2ZDBlYjFkNTY3MjM0MzRi
|
14
|
+
ZTFiMzNlYmQzZWU3ZTZiYjk3YmFhNWNhNWYxN2M2YTM5Yjc5MGJiYWRhZTQy
|
15
|
+
ZWU5NWIyMDc1ZGE0ZDVlM2FlYjFmMDczNjQ1ZWExMmMxNWIxZTc=
|
data/lib/runby_pace.rb
CHANGED
data/lib/runby_pace/pace_data.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Runby
|
2
2
|
# Encapsulates the algorithms used to calculate target paces.
|
3
3
|
class PaceData
|
4
4
|
# The number of data points plotted on our line of 5K times.
|
@@ -26,8 +26,8 @@ module RunbyPace
|
|
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 = Runby::PaceTime.new(fastest_pace_km)
|
30
|
+
@slowest_pace_km = Runby::PaceTime.new(slowest_pace_km)
|
31
31
|
@midpoint_radius_divisor = midpoint_radius_divisor
|
32
32
|
end
|
33
33
|
|
@@ -38,11 +38,11 @@ module RunbyPace
|
|
38
38
|
|
39
39
|
# Calculate the prescribed pace for the given 5K time
|
40
40
|
def calc(five_k_time, distance_units = :km)
|
41
|
-
five_k_time =
|
41
|
+
five_k_time = Runby::PaceTime.new(five_k_time)
|
42
42
|
x2 = ((five_k_time.total_minutes * 2) - (MIDPOINT_X - 1)) - 1
|
43
43
|
minutes_per_km = slope * x2 + @fastest_pace_km.total_minutes + curve_minutes(x2)
|
44
|
-
minutes_per_unit = minutes_per_km *
|
45
|
-
|
44
|
+
minutes_per_unit = minutes_per_km * Runby::PaceUnits.distance_conversion_factor(distance_units)
|
45
|
+
Runby::PaceTime.from_minutes(minutes_per_unit)
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -1,17 +1,17 @@
|
|
1
1
|
require_relative 'runby_range'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Runby
|
4
4
|
# Represents a range of paces, from fast to slow.
|
5
5
|
class PaceRange < RunbyRange
|
6
6
|
def initialize(fast, slow)
|
7
|
-
@fast =
|
8
|
-
@slow =
|
7
|
+
@fast = Runby::PaceTime.new(fast)
|
8
|
+
@slow = Runby::PaceTime.new(slow)
|
9
9
|
end
|
10
10
|
|
11
11
|
# Create a new pace range from an existing speed range.
|
12
12
|
def self.from_speed_range(speed_range)
|
13
|
-
fast =
|
14
|
-
slow =
|
13
|
+
fast = Runby::RunMath.convert_speed_to_pace speed_range.fast
|
14
|
+
slow = Runby::RunMath.convert_speed_to_pace speed_range.slow
|
15
15
|
PaceRange.new fast, slow
|
16
16
|
end
|
17
17
|
end
|
data/lib/runby_pace/pace_time.rb
CHANGED
data/lib/runby_pace/run_math.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
module
|
1
|
+
module Runby
|
2
2
|
# An assortment of mathematical functions related to running.
|
3
3
|
class RunMath
|
4
4
|
def self.convert_pace_to_speed(pace)
|
5
|
-
pace =
|
5
|
+
pace = Runby::PaceTime.new(pace)
|
6
6
|
(60 / pace.total_minutes).round(2)
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.convert_speed_to_pace(units_per_hour)
|
10
10
|
raise 'units_per_hour must be numeric' unless units_per_hour.is_a? Numeric
|
11
|
-
|
11
|
+
Runby::PaceTime.from_minutes(60.0 / units_per_hour)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.distance_traveled(pace, time)
|
15
15
|
# TODO: I sense the need for a refactor...
|
16
16
|
# Consider extracting a new Pace class, which consists of Time + Units
|
17
17
|
# Then move this method to the new class, and give it a better name.
|
18
|
-
pace =
|
19
|
-
time =
|
18
|
+
pace = Runby::PaceTime.new(pace)
|
19
|
+
time = Runby::PaceTime.new(time)
|
20
20
|
|
21
21
|
divisor = pace.total_minutes / time.total_minutes
|
22
22
|
distance_units_traveled = 1 / divisor
|
data/lib/runby_pace/run_type.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module Runby
|
2
2
|
# Base class for all run types
|
3
3
|
class RunType
|
4
4
|
def description
|
@@ -15,7 +15,7 @@ module RunbyPace
|
|
15
15
|
module RunTypes
|
16
16
|
# Returns an initialized run type, given the name of an existing run type
|
17
17
|
def self.new_from_name(run_type_name)
|
18
|
-
Object.const_get("
|
18
|
+
Object.const_get("Runby::RunTypes::#{run_type_name}").new
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module
|
1
|
+
module Runby
|
2
2
|
# Extend RunTypes with additional behavior. (See comments for details)
|
3
3
|
module RunTypes
|
4
4
|
# Currently, to find the radius of the curve in the pace table data for a given run time,
|
5
5
|
# we start with a radius equal to that of the midpoint of the X axis for the data when
|
6
6
|
# plotted on a graph. Then we use a radius divisor for the PaceData for each run type to
|
7
|
-
# dial in the height of the curve. (See
|
7
|
+
# dial in the height of the curve. (See Runby::PaceData)
|
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.
|
@@ -20,8 +20,8 @@ module RunbyPace
|
|
20
20
|
viable_divisor = nil
|
21
21
|
|
22
22
|
golden_paces.each do |five_k, golden_pace|
|
23
|
-
five_k_time =
|
24
|
-
pace_data =
|
23
|
+
five_k_time = Runby::PaceTime.new(five_k.to_s)
|
24
|
+
pace_data = Runby::PaceData.new(first_pace, last_pace, candidate_divisor)
|
25
25
|
calculated_pace = pace_data.calc(five_k_time)
|
26
26
|
unless calculated_pace.almost_equals?(golden_pace, allowable_deviation)
|
27
27
|
viable_divisor = nil
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'runby_range'
|
2
2
|
|
3
|
-
module
|
3
|
+
module Runby
|
4
4
|
# Represents a range of speeds, from fast to slow.
|
5
5
|
class SpeedRange < RunbyRange
|
6
6
|
def initialize(fast, slow)
|
@@ -11,8 +11,8 @@ module RunbyPace
|
|
11
11
|
|
12
12
|
# Create a new speed range from an existing pace range.
|
13
13
|
def self.from_pace_range(pace_range)
|
14
|
-
fast =
|
15
|
-
slow =
|
14
|
+
fast = Runby::RunMath.convert_pace_to_speed pace_range.fast
|
15
|
+
slow = Runby::RunMath.convert_pace_to_speed pace_range.slow
|
16
16
|
SpeedRange.new fast, slow
|
17
17
|
end
|
18
18
|
end
|
data/lib/runby_pace/version.rb
CHANGED
data/runby_pace.gemspec
CHANGED
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.2.
|
4
|
+
version: 0.2.75
|
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-08-
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -97,7 +97,7 @@ homepage: https://github.com/tygerbytes/runby-pace
|
|
97
97
|
licenses:
|
98
98
|
- MIT
|
99
99
|
metadata:
|
100
|
-
commit-hash:
|
100
|
+
commit-hash: 8cf22b765ba8397084356c114f0476c6e39e627a
|
101
101
|
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|