runby_pace 0.2.57 → 0.2.58

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
- NTVjYWZlYmVhMzZmOTY3ZGM0NDIzMTk4ZjhkNWU4MmJmYWI2YzBlMw==
4
+ YTgyY2I1MjZkZDAzOTJlMDQzYmFlN2YyMGNjMTg1NjY5NGMxMmRhOQ==
5
5
  data.tar.gz: !binary |-
6
- MDQzNTI4MWZiNTczMWRkYzllYzZhODY2NmNjMDk0OGRjYjU1NWQyNQ==
6
+ NWEzMWI1YThlMWY2NDI1NzBjYjEzMDllNjFmYzhiNGMyNGRkYzk3OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWE0ZjQ5ZjA3OTRiNTllNjk1NjgxOGQxYWIwY2IyZDg4NzBkZTYyZmVjZWM3
10
- ZmIzY2E1ZTc3NjU3ZjNmNDVkNzJkNjI3MDA1Mzc5OWE3YWUwODdlOTZhZWM0
11
- MzEyYjM3MTJlYjRmYmQ0NWJkODlhNTA2ZDBlMmQzN2MxNDNjNTM=
9
+ NjRiMGZkZjlkZDFlNjQ1Yzk2ZmVlYTRhMGRiNmNkYTdlMmE0N2MxYzg0NzQ0
10
+ M2JiMWE0NTA3ZWI2MjZkMTMzYWE1ZGJlYTgwNmFlMzYwMjNlY2UyOTc4Njlk
11
+ Mjk0ZDJjZmE5M2UwYzg0OTMyNDlhOWRhNjNhZTlkNGIyNDM5MWM=
12
12
  data.tar.gz: !binary |-
13
- YmY3N2EwZGNiMmUxNWY3ZTA0ZmRjNzI2MGY0MDI1OGY4ZTdmMGE1ZmM2YzZi
14
- ODM1MWY5ZmY0MGE4ZTVhMjg5NzU2ZGJkZDkyMWMxZGExYzRkNmE2YmIwZGYw
15
- MGI2N2JmYTliMzc4OGI3YTk3MDJhZGQyNTM5ZDdhYzY0YmU1N2M=
13
+ MzAxNjU2ZGU3ZDcwNTMzOGNjYTkxNjJmNWQwZWRlYWJhYzFhMzllNmU3ZTQ2
14
+ MmEwZGRmYzA0OWY3OGZmYTljZWQ1NjU2ZTkzMzNiOGRlNjBiMjlhNjFjMmQy
15
+ YzJjZmVkNDEyYzEwZTA2ZmFkNGNhNzM4ZmZiNDc0MjA4NDIzMjY=
@@ -38,10 +38,12 @@ module RunbyPace
38
38
  end
39
39
 
40
40
  # Calculate the prescribed pace for the given 5K time
41
- def calc(five_k_time)
41
+ def calc(five_k_time, distance_units = :km)
42
42
  five_k_time = RunbyPace::PaceTime.new(five_k_time)
43
43
  x2 = ((five_k_time.total_minutes * 2) - (MIDPOINT_X - 1)) - 1
44
- RunbyPace::PaceTime.from_minutes(slope * x2 + @fastest_pace_km.total_minutes + curve_minutes(x2))
44
+ minutes_per_km = slope * x2 + @fastest_pace_km.total_minutes + curve_minutes(x2)
45
+ minutes_per_unit = minutes_per_km * RunbyPace::PaceUnits.distance_conversion_factor(distance_units)
46
+ RunbyPace::PaceTime.from_minutes(minutes_per_unit)
45
47
  end
46
48
 
47
49
  private
@@ -0,0 +1,24 @@
1
+ module RunbyPace
2
+
3
+ class PaceUnits
4
+
5
+ def self.description(units)
6
+ descriptions[units]
7
+ end
8
+
9
+ def self.distance_conversion_factor(units)
10
+ self.distance_conversion_factors[units]
11
+ end
12
+
13
+ private
14
+
15
+ def self.descriptions
16
+ { :km => 'Kilometers', :mi => 'Miles' }
17
+ end
18
+
19
+ def self.distance_conversion_factors
20
+ { :km => 1.0, :mi => 1.612903225806452 }
21
+ end
22
+
23
+ end
24
+ end
@@ -5,7 +5,7 @@ module RunbyPace
5
5
  'No description'
6
6
  end
7
7
 
8
- def pace(five_k_time)
8
+ def pace(five_k_time, distance_units = :km)
9
9
  end
10
10
  end
11
11
 
@@ -14,9 +14,9 @@ module RunbyPace
14
14
  @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 2.175)
15
15
  end
16
16
 
17
- def pace(five_k_time)
18
- fast = @fast_pace_data.calc(five_k_time)
19
- slow = @slow_pace_data.calc(five_k_time)
17
+ def pace(five_k_time, distance_units = :km)
18
+ fast = @fast_pace_data.calc(five_k_time, distance_units)
19
+ slow = @slow_pace_data.calc(five_k_time, distance_units)
20
20
  PaceRange.new(fast, slow)
21
21
  end
22
22
 
@@ -14,9 +14,9 @@ module RunbyPace
14
14
  @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 1.35)
15
15
  end
16
16
 
17
- def pace(five_k_time)
18
- fast = @fast_pace_data.calc(five_k_time)
19
- slow = @slow_pace_data.calc(five_k_time)
17
+ def pace(five_k_time, distance_units = :km)
18
+ fast = @fast_pace_data.calc(five_k_time, distance_units)
19
+ slow = @slow_pace_data.calc(five_k_time, distance_units)
20
20
  PaceRange.new(fast, slow)
21
21
  end
22
22
 
@@ -14,8 +14,8 @@ module RunbyPace
14
14
  @slow_pace_data = @fast_pace_data
15
15
  end
16
16
 
17
- def pace(five_k_time)
18
- fast = @fast_pace_data.calc(five_k_time)
17
+ def pace(five_k_time, distance_units = :km)
18
+ fast = @fast_pace_data.calc(five_k_time, distance_units)
19
19
  slow = fast
20
20
  PaceRange.new(fast, slow)
21
21
  end
@@ -14,9 +14,9 @@ module RunbyPace
14
14
  @slow_pace_data = PaceData.new(GoldenPaces::slow[:'14:00'], GoldenPaces::slow[:'42:00'], 1.55)
15
15
  end
16
16
 
17
- def pace(five_k_time)
18
- fast = @fast_pace_data.calc(five_k_time)
19
- slow = @slow_pace_data.calc(five_k_time)
17
+ def pace(five_k_time, distance_units = :km)
18
+ fast = @fast_pace_data.calc(five_k_time, distance_units)
19
+ slow = @slow_pace_data.calc(five_k_time, distance_units)
20
20
  PaceRange.new(fast, slow)
21
21
  end
22
22
 
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.57
4
+ version: 0.2.58
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-07-05 00:00:00.000000000 Z
11
+ date: 2016-07-06 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/pace_data.rb
76
76
  - lib/runby_pace/pace_range.rb
77
77
  - lib/runby_pace/pace_time.rb
78
+ - lib/runby_pace/pace_units.rb
78
79
  - lib/runby_pace/run_type.rb
79
80
  - lib/runby_pace/run_types/all_run_types.g.rb
80
81
  - lib/runby_pace/run_types/all_run_types.template
@@ -90,7 +91,7 @@ homepage: https://github.com/tygerbytes/runby-pace
90
91
  licenses:
91
92
  - MIT
92
93
  metadata:
93
- commit-hash: 172f78652e8dd2636e77a9ea8d7a5ff5f17a7ed1
94
+ commit-hash: 3324995a96d26ca7dac336e57ea4b1f05110e160
94
95
  post_install_message:
95
96
  rdoc_options: []
96
97
  require_paths: