runby_pace 0.2.37 → 0.2.39

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2I4ODIwNjNhYmI5NGIwYmU5MWExOTA4ZWIwMmY5ZWIyMmI1ZTc4Yw==
4
+ NGY2YTlhYTRlYWE4ZWIyZTU0Mzc3N2VhN2I2YmIxOTlhODlhYTU0NA==
5
5
  data.tar.gz: !binary |-
6
- ZjkzZDZhNzBlNGUzNjM1ZDlmOWIyZDM1N2Q3MzMzY2IyZGM4NTc1Yg==
6
+ YWQ1YzI1YzE0ZWYxODQzY2RmZDEwY2QzMjFmNzE2YjVhODQzMTYzYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmRjODlhZTViZGY4MmExNmFkOWM0YjAyY2U5NjcxY2Q5OTVkZWIwZjA5MzM1
10
- NDgyYmVmNmU4NzViOGM1OWI5ZTQ0N2U5NTBkOGY0Njg4YWE3ODBiZGE3ZGEx
11
- YTgwMmEyOTc0MTdkMzBiNDM1N2Q3ZTQ4N2Q1ZDYxM2FhMGIwMzM=
9
+ NzQxMzM4OWY1ZGFmODNiMmFiYWUzMWViMDlhN2RhMjVlMmRiNDIzOWUyMGM5
10
+ NWNkYjY1MjI4MzE3MDYyYzljYTE0NGUwMWU4YmE3NzU1YTVhNDhlNjY0Mjkz
11
+ ZWU1NzE2ZGIzMTc0NmM1Njc3ODU4OTE1YzNlZTljNzg2MjQ5OWQ=
12
12
  data.tar.gz: !binary |-
13
- Mjc5NjM0YzRmN2ZiMDkzODMwNTdlM2Y3ZGVhN2Y5MDdhNzIxMWEwY2M2OWFk
14
- OWZlYTA5NmM3MTU4OWE3MzhkNGY4OWFkOGE4NDM5ZGFhY2Q2YjE4M2Y5Njhk
15
- OGI5MWYxNDBkYWE3MjhkZDA3NDA3ZGU2YzM1NDRlYjBlZjNlZWQ=
13
+ YWJlNGM1MmIzYjIwZjQyYjUwOGMwNDU4ZDc4YWYzMzFkY2I0OGQ5NDUzOTNi
14
+ NjE4ZDcyYmVmMjgwZWIwMGQ0MzUzMDJhZGNjZDI3YTUyNTY3NWJkYzcxZWYy
15
+ Mzc4NGM2MWUzNGQ5Y2I4MWExNjA4ZjYzYTlhY2VjM2NjNWFmZDg=
@@ -57,6 +57,14 @@ module RunbyPace
57
57
  end
58
58
  end
59
59
 
60
+ def almost_equals?(other_time, tolerance_time = '00:01')
61
+ if other_time.is_a?(String)
62
+ other_time = PaceTime.new(other_time)
63
+ end
64
+ tolerance = PaceTime.new(tolerance_time)
65
+ self >= (other_time - tolerance) && self <= (other_time + tolerance)
66
+ end
67
+
60
68
  def >(value)
61
69
  if value.is_a?(PaceTime)
62
70
  total_seconds > value.total_seconds
@@ -0,0 +1,47 @@
1
+ module RunbyPace
2
+
3
+ module RunTypes
4
+
5
+ # Currently, to find the radius of the curve in the pace table data for a given run time,
6
+ # we start with a radius equal to that of the midpoint of the X axis for the data when
7
+ # plotted on a graph. Then we use a radius divisor for the PaceData for each run type to
8
+ # dial in the height of the curve. (See RunbyPace::PaceData)
9
+ # This method, #find_divisor, accepts a hash of "golden paces" for a run type along with
10
+ # the number of seconds of allowable deviation from the golden pace. Then it proceeds
11
+ # to brute force the divisor.
12
+ # @param [Hash] golden_paces
13
+ # @param [String] allowable_deviation
14
+ # @return [decimal]
15
+ def self.find_divisor(golden_paces, allowable_deviation = '00:01')
16
+ _, first_pace = golden_paces.first
17
+ last_pace = golden_paces[:'42:00']
18
+ viable_divisors = []
19
+
20
+ (1.0..5.0).step(0.025) do |candidate_divisor|
21
+ viable_divisor = nil
22
+
23
+ golden_paces.each do |five_k, golden_pace|
24
+ five_k_time = RunbyPace::PaceTime.new(five_k.to_s)
25
+ pace_data = RunbyPace::PaceData.new(first_pace, last_pace, candidate_divisor)
26
+ calculated_pace = pace_data.calc(five_k_time)
27
+ if !calculated_pace.almost_equals?(golden_pace, allowable_deviation)
28
+ viable_divisor = nil
29
+ break
30
+ end
31
+ viable_divisor = candidate_divisor
32
+ end
33
+
34
+ if viable_divisor != nil
35
+ viable_divisors << viable_divisor
36
+ end
37
+ end
38
+
39
+ if viable_divisors.length > 0
40
+ # puts viable_divisors
41
+ midpoint = (viable_divisors.length - 1) / 2
42
+ return viable_divisors[midpoint]
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -6,7 +6,7 @@ module RunbyPace
6
6
  attr_reader :slow_pace_data, :fast_pace_data
7
7
 
8
8
  def initialize
9
- @fast_pace_data = PaceData.new(GoldenPaces::fast[:'14:00'], GoldenPaces::fast[:'42:00'], 1.99)
9
+ @fast_pace_data = PaceData.new(GoldenPaces::fast[:'14:00'], GoldenPaces::fast[:'42:00'], 2.125)
10
10
  @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 1.55)
11
11
  end
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runby_pace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.37
4
+ version: 0.2.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ty Walls
@@ -77,6 +77,7 @@ files:
77
77
  - lib/runby_pace/pace_time.rb
78
78
  - lib/runby_pace/run_type.rb
79
79
  - lib/runby_pace/run_types/easy_run.rb
80
+ - lib/runby_pace/run_types/find_divisor.rb
80
81
  - lib/runby_pace/run_types/long_run.rb
81
82
  - lib/runby_pace/version.rb
82
83
  - misc/rubymine.png
@@ -85,7 +86,7 @@ homepage: https://github.com/tygerbytes/runby-pace
85
86
  licenses:
86
87
  - MIT
87
88
  metadata:
88
- commit-hash: 017ff7a10d3534444ba4dbb583ab25ec1c0b09a3
89
+ commit-hash: 5f86274f5a5559bef342192fbde4d81fae1289e8
89
90
  post_install_message:
90
91
  rdoc_options: []
91
92
  require_paths: