runby_pace 0.3.76 → 0.4.77

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWQ4NDI1YjI5NDMyZjliYTdjMDk3YTZjNzlhYTc5MWVkYjVkMWVjOA==
4
+ NjQyMjM2ZWNlZjdhYmY2OGEyMTk5YzdlZTA5ZDcwZWExNmI4N2ZmZQ==
5
5
  data.tar.gz: !binary |-
6
- NTcyZGQzYTQ0ODBlOTZiMjFkMDg4YmNiN2IyM2Y5ODQ0ZDhiMzg4Yg==
6
+ YTYyYzQ1MTdjZTUwMjIyZGRjMjY5YTIwZjIyZmQ5ZmM0OWQxZmZlMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YmU5ZTE5NTZlYTgyZWFiYmMwOTVjNzkzNjM0MThkMmYzN2JmODg2YjM4OTZm
10
- ZmM0OWIzYWQ5NWIzNzgxNDZmM2Y0YmRiZDE5NTE0MGYxNWZjNjU2MTA0ZTMy
11
- MjNiNWUyMDQ0OWU1MjBiNTE3NDlhOTRiYjQzNWNjZmRjNDNmNGQ=
9
+ ODdhZTk4OTFkNTA0MDczZmVmMjVjNWMzOWU1ZTZmMzQ2NWI1MWYxNWFlZTY2
10
+ NTc3ZjU1ODFiMzFhYmFjNTVkMWEzOGI2N2QxNTQ2MmFmYjlmZWQ0NTVlMTBh
11
+ YWJkZTU0NjVhYjYyYjFiNmVlMjgwODRjM2NhOWUyODY1NDFiYjc=
12
12
  data.tar.gz: !binary |-
13
- MGUxMWE0NjUzMmMyYTQ4OGIxNDM4NDczMGY4YmYyMjVjODcyMGVjMzJjMjhl
14
- NzhmNDg0OTNkNmY1OGMxMzhlMjU0NzA2YThhMDc1NTcyODViNmJjZDllYjAw
15
- YjlhMzAzYTMzMmNmYmU0YTk3OTg1ZjVhNjQ1NGM0ZDdkMjdjOTY=
13
+ ZTVmZmU4YThkY2NhZWE3MWM4ZjMyNWIyZmQ2MzdmZTdlMTI5MTdlMWE2YWY2
14
+ OTA4Mzc5MWM4N2U4MjBlNTEyNzJiNTNkYzU5NGFlMjU1YzAyZjM2OGRmNjM1
15
+ OGI2ZGFkYjZmYjRiYzM5ZmQ1YjU1YzIwZWZkMzM4MjdiYjg4M2Q=
@@ -26,8 +26,8 @@ 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 = Runby::PaceTime.new(fastest_pace_km)
30
- @slowest_pace_km = Runby::PaceTime.new(slowest_pace_km)
29
+ @fastest_pace_km = Runby::RunbyTime.new(fastest_pace_km)
30
+ @slowest_pace_km = Runby::RunbyTime.new(slowest_pace_km)
31
31
  @midpoint_radius_divisor = midpoint_radius_divisor
32
32
  end
33
33
 
@@ -38,11 +38,11 @@ module Runby
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 = Runby::PaceTime.new(five_k_time)
41
+ five_k_time = Runby::RunbyTime.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
44
  minutes_per_unit = minutes_per_km * Runby::PaceUnits.distance_conversion_factor(distance_units)
45
- Runby::PaceTime.from_minutes(minutes_per_unit)
45
+ Runby::RunbyTime.from_minutes(minutes_per_unit)
46
46
  end
47
47
 
48
48
  private
@@ -4,8 +4,8 @@ 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 = Runby::PaceTime.new(fast)
8
- @slow = Runby::PaceTime.new(slow)
7
+ @fast = Runby::RunbyTime.new(fast)
8
+ @slow = Runby::RunbyTime.new(slow)
9
9
  end
10
10
 
11
11
  # Create a new pace range from an existing speed range.
@@ -2,21 +2,21 @@ 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 = Runby::PaceTime.new(pace)
5
+ pace = Runby::RunbyTime.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
- Runby::PaceTime.from_minutes(60.0 / units_per_hour)
11
+ Runby::RunbyTime.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 = Runby::PaceTime.new(pace)
19
- time = Runby::PaceTime.new(time)
18
+ pace = Runby::RunbyTime.new(pace)
19
+ time = Runby::RunbyTime.new(time)
20
20
 
21
21
  divisor = pace.total_minutes / time.total_minutes
22
22
  distance_units_traveled = 1 / divisor
@@ -20,7 +20,7 @@ module Runby
20
20
  viable_divisor = nil
21
21
 
22
22
  golden_paces.each do |five_k, golden_pace|
23
- five_k_time = Runby::PaceTime.new(five_k.to_s)
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
26
  unless calculated_pace.almost_equals?(golden_pace, allowable_deviation)
@@ -1,12 +1,12 @@
1
1
  module Runby
2
2
  # Represents a human-readable time in the format MM:ss
3
- class PaceTime
3
+ class RunbyTime
4
4
  attr_reader :time_s, :minutes_part, :seconds_part
5
5
 
6
6
  def initialize(time)
7
7
  if time.is_a?(String) || time.is_a?(Symbol)
8
8
  init_from_string time
9
- elsif time.is_a?(PaceTime)
9
+ elsif time.is_a?(RunbyTime)
10
10
  init_from_clone time
11
11
  elsif time.is_a?(Hash)
12
12
  init_from_hash time
@@ -17,7 +17,7 @@ module Runby
17
17
  def self.from_seconds(total_seconds)
18
18
  minutes = total_seconds.abs.to_i / 60
19
19
  seconds = total_seconds.abs.to_i % 60
20
- PaceTime.new format('%02d:%02d', minutes, seconds)
20
+ RunbyTime.new format('%02d:%02d', minutes, seconds)
21
21
  end
22
22
 
23
23
  # @param [numeric] total_minutes
@@ -57,7 +57,7 @@ module Runby
57
57
  end
58
58
  time_formatted = "#{minutes_part.to_s.rjust(2, '0')}:#{seconds_part.to_s.rjust(2, '0')}"
59
59
 
60
- PaceTime.new(time_s: time_formatted, minutes_part: minutes_part, seconds_part: seconds_part)
60
+ RunbyTime.new(time_s: time_formatted, minutes_part: minutes_part, seconds_part: seconds_part)
61
61
  end
62
62
 
63
63
  def self.try_parse(str, is_five_k = false)
@@ -89,22 +89,22 @@ module Runby
89
89
  @minutes_part + (@seconds_part / 60.0)
90
90
  end
91
91
 
92
- # @param [PaceTime] other
92
+ # @param [RunbyTime] other
93
93
  def -(other)
94
- if other.is_a?(PaceTime)
95
- PaceTime.from_seconds(total_seconds - other.total_seconds)
94
+ if other.is_a?(RunbyTime)
95
+ RunbyTime.from_seconds(total_seconds - other.total_seconds)
96
96
  end
97
97
  end
98
98
 
99
- # @param [PaceTime] other
99
+ # @param [RunbyTime] other
100
100
  def +(other)
101
- if other.is_a?(PaceTime)
102
- PaceTime.from_seconds(total_seconds + other.total_seconds)
101
+ if other.is_a?(RunbyTime)
102
+ RunbyTime.from_seconds(total_seconds + other.total_seconds)
103
103
  end
104
104
  end
105
105
 
106
106
  def ==(other)
107
- if other.is_a?(PaceTime)
107
+ if other.is_a?(RunbyTime)
108
108
  total_seconds == other.total_seconds
109
109
  elsif other.is_a?(String)
110
110
  @time_s == other
@@ -113,32 +113,32 @@ module Runby
113
113
 
114
114
  def almost_equals?(other_time, tolerance_time = '00:01')
115
115
  if other_time.is_a?(String)
116
- other_time = PaceTime.new(other_time)
116
+ other_time = RunbyTime.new(other_time)
117
117
  end
118
- tolerance = PaceTime.new(tolerance_time)
118
+ tolerance = RunbyTime.new(tolerance_time)
119
119
  self >= (other_time - tolerance) && self <= (other_time + tolerance)
120
120
  end
121
121
 
122
122
  def >(other)
123
- if other.is_a?(PaceTime)
123
+ if other.is_a?(RunbyTime)
124
124
  total_seconds > other.total_seconds
125
125
  end
126
126
  end
127
127
 
128
128
  def >=(other)
129
- if other.is_a?(PaceTime)
129
+ if other.is_a?(RunbyTime)
130
130
  total_seconds >= other.total_seconds
131
131
  end
132
132
  end
133
133
 
134
134
  def <(other)
135
- if other.is_a?(PaceTime)
135
+ if other.is_a?(RunbyTime)
136
136
  total_seconds < other.total_seconds
137
137
  end
138
138
  end
139
139
 
140
140
  def <=(other)
141
- if other.is_a?(PaceTime)
141
+ if other.is_a?(RunbyTime)
142
142
  total_seconds <= other.total_seconds
143
143
  end
144
144
  end
@@ -152,7 +152,7 @@ module Runby
152
152
  @seconds_part = params.fetch :seconds_part, 0.0
153
153
  end
154
154
 
155
- # @param [PaceTime] time
155
+ # @param [RunbyTime] time
156
156
  def init_from_clone(time)
157
157
  @time_s = time.time_s
158
158
  @minutes_part = time.minutes_part
@@ -161,7 +161,7 @@ module Runby
161
161
 
162
162
  # @param [String] time
163
163
  def init_from_string(time)
164
- init_from_clone PaceTime.parse time
164
+ init_from_clone RunbyTime.parse time
165
165
  end
166
166
  end
167
167
  end
@@ -1,3 +1,3 @@
1
1
  module Runby
2
- VERSION = "0.3.#{`git rev-list --count HEAD`}".freeze
2
+ VERSION = "0.4.#{`git rev-list --count HEAD`}".freeze
3
3
  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.3.76
4
+ version: 0.4.77
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-24 00:00:00.000000000 Z
11
+ date: 2016-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,7 +75,6 @@ files:
75
75
  - lib/runby_pace.rb
76
76
  - lib/runby_pace/pace_data.rb
77
77
  - lib/runby_pace/pace_range.rb
78
- - lib/runby_pace/pace_time.rb
79
78
  - lib/runby_pace/pace_units.rb
80
79
  - lib/runby_pace/run_math.rb
81
80
  - lib/runby_pace/run_type.rb
@@ -89,6 +88,7 @@ files:
89
88
  - lib/runby_pace/run_types/slow_tempo_run.rb
90
89
  - lib/runby_pace/run_types/tempo_run.rb
91
90
  - lib/runby_pace/runby_range.rb
91
+ - lib/runby_pace/runby_time.rb
92
92
  - lib/runby_pace/speed_range.rb
93
93
  - lib/runby_pace/version.rb
94
94
  - misc/rubymine.png
@@ -97,7 +97,7 @@ homepage: https://github.com/tygerbytes/runby-pace
97
97
  licenses:
98
98
  - MIT
99
99
  metadata:
100
- commit-hash: aebd8428af5cd3d5c712bf28d83f3459e0df8ec9
100
+ commit-hash: aaec1286959731a10a4561c4cc9302970703f297
101
101
  post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths: