runby_pace 0.2.72 → 0.2.73

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
- YTM2ZGQ2YmIyZmNkMGM0NGViOTdiZTQzMjY4YTBmNzA0ZjQ3NWNhZg==
4
+ NzRhMDJiMDg2YzY0YjdjMTQ4OGFhOTlmMDNmMzA2ODgyM2I2Zjk0Ng==
5
5
  data.tar.gz: !binary |-
6
- N2I4M2M2MjRhY2IzMDkxZmEwN2NkOTIyMTUzNDc3ZTNkNmFmMDg5Yw==
6
+ NzAyNmRmMmE3MTcxY2QyYTEzMTRkZDc3OTBmOTFiNTBiYmUzOGQyMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWFjOWY4MTU5ZDdmZTI4NWM0Njk5MDcxMTQ2YzdiN2Q0MDY0MTg4MGI3NjBj
10
- OTZjZjExMmMxMGIxYzQ3ZTE1NjI5N2JkYTMxMjgwMWViZDU1MDNlNGZlNDYy
11
- NGI3MjA1NTVmOGE5YTljOTA0MmE1NDExZDQ2NTU1MDc5NzExNTc=
9
+ NDhiMWQ5ODE4ZGI4Nzg2ZDVhOTM4MjhiNTU1ZjU0NzVjYTc0ZGNkZjVlMmRj
10
+ ODRhMWJhMGYyY2RmNjY1MTEzNTIxYjM2NWY4NTlkZmVlOTcxMDczNDM4MTg5
11
+ ZjlhNTZhMmQxYzJiZmY5NDFhYjk3ZjVkNTI4NmI3OGIxOTgzZTM=
12
12
  data.tar.gz: !binary |-
13
- NDRkYmFkN2UwNTg5ODI4MTgwYWUzOGJhNDEzYzJkYTEwZWJlY2Y1YzZiNzY1
14
- ZGVkODcxYTg5ZDM0MTZkNzViZGYxMzFiYWE1MWE5YjI1ZDM0Zjg0MzM0NDEy
15
- MDE4ZDUyYmIzNzkzMWQ1ZTA3ZmRlZmI4YTRiMWYwNTBjMjA2YzY=
13
+ MDEwNzQ2NWU0MWZiYTk5MGFjNzJhNzJlZThiNGI5ZDRjMjlmODc1ZDE5NDdh
14
+ YTAzZmZkOGFlYzJmZjI1ZTA0YTY2NjJkMjhiYzQ0ZjYyMGI3MmRjYTI0NzMz
15
+ ODgyNTU1YTQyZjBjNTkyNjE2ODE5MGNlMjdkZTZiYmUwNDBkYTE=
@@ -8,6 +8,7 @@ module RunbyPace
8
8
  @slow = RunbyPace::PaceTime.new(slow)
9
9
  end
10
10
 
11
+ # Create a new pace range from an existing speed range.
11
12
  def self.from_speed_range(speed_range)
12
13
  fast = RunbyPace::RunMath.convert_speed_to_pace speed_range.fast
13
14
  slow = RunbyPace::RunMath.convert_speed_to_pace speed_range.slow
@@ -17,7 +17,7 @@ module RunbyPace
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
+ PaceTime.new format('%02d:%02d', minutes, seconds)
21
21
  end
22
22
 
23
23
  # @param [numeric] total_minutes
@@ -1,4 +1,7 @@
1
1
  module RunbyPace
2
+ # Represents the distance units (e.g. kilometers, miles) used in paces
3
+ # including the human-readable description of each unit
4
+ # and the factor used to convert it to kilometers.
2
5
  class PaceUnits
3
6
  def self.description(units)
4
7
  descriptions[units]
@@ -8,13 +11,13 @@ module RunbyPace
8
11
  distance_conversion_factors[units]
9
12
  end
10
13
 
11
- private
14
+ ### -- Private class methods --
12
15
 
13
- def self.descriptions
16
+ private_class_method def self.descriptions
14
17
  { km: 'Kilometers', mi: 'Miles' }
15
18
  end
16
19
 
17
- def self.distance_conversion_factors
20
+ private_class_method def self.distance_conversion_factors
18
21
  { km: 1.0, mi: 1.612903225806452 }
19
22
  end
20
23
  end
@@ -1,4 +1,5 @@
1
1
  module RunbyPace
2
+ # An assortment of mathematical functions related to running.
2
3
  class RunMath
3
4
  def self.convert_pace_to_speed(pace)
4
5
  pace = RunbyPace::PaceTime.new(pace)
@@ -1,4 +1,5 @@
1
1
  module RunbyPace
2
+ # Base class for all run types
2
3
  class RunType
3
4
  def description
4
5
  'No description'
@@ -8,7 +9,11 @@ module RunbyPace
8
9
  end
9
10
  end
10
11
 
12
+ # Extends RunTypes with additional methods.
13
+ # Since RunTypes is autogenerated in all_run_types.g.rb, we needed a safe way of adding behavior to it
14
+ # without complicating the codegen.
11
15
  module RunTypes
16
+ # Returns an initialized run type, given the name of an existing run type
12
17
  def self.new_from_name(run_type_name)
13
18
  Object.const_get("RunbyPace::RunTypes::#{run_type_name}").new
14
19
  end
@@ -1,6 +1,7 @@
1
1
  # This file is automatically generated by a rake task
2
2
 
3
3
  module RunbyPace
4
+ # Encapsulates data and behavior relating to all run types.
4
5
  module RunTypes
5
6
  def self.all
6
7
  %w(__RUN_TYPES__)
@@ -1,5 +1,7 @@
1
1
  module RunbyPace
2
2
  module RunTypes
3
+ # Defines the venerable "distance run", the backbone of any distance running program.
4
+ # Most of your runs should be at this pace. Harder than an "easy run" but still conversational.
3
5
  class DistanceRun < RunType
4
6
  attr_reader :slow_pace_data, :fast_pace_data
5
7
 
@@ -18,6 +20,7 @@ module RunbyPace
18
20
  PaceRange.new(fast, slow)
19
21
  end
20
22
 
23
+ # Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
21
24
  class GoldenPaces
22
25
  def self.fast
23
26
  { '14:00': '03:44', '15:00': '03:58', '20:00': '05:09', '25:00': '06:18', '30:00': '07:24', '35:00': '08:29', '40:00': '09:33', '42:00': '09:58' }
@@ -1,5 +1,6 @@
1
1
  module RunbyPace
2
2
  module RunTypes
3
+ # An easy run is basically a jog. It should be conversational.
3
4
  class EasyRun < RunType
4
5
  attr_reader :slow_pace_data, :fast_pace_data
5
6
 
@@ -18,6 +19,7 @@ module RunbyPace
18
19
  PaceRange.new(fast, slow)
19
20
  end
20
21
 
22
+ # Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
21
23
  class GoldenPaces
22
24
  def self.fast
23
25
  { '14:00': '04:17', '15:00': '04:33', '20:00': '05:53', '25:00': '07:09', '30:00': '08:23', '35:00': '09:33', '40:00': '10:41', '42:00': '11:08' }
@@ -2,6 +2,8 @@ require_relative 'tempo_run'
2
2
 
3
3
  module RunbyPace
4
4
  module RunTypes
5
+ # The "fast tempo" pace roughly equates to your half-marathon pace.
6
+ # It's a pace you could maintain for about an hour, if pressed.
5
7
  class FastTempoRun < TempoRun
6
8
  def description
7
9
  'Fast Tempo Run'
@@ -1,4 +1,5 @@
1
1
  module RunbyPace
2
+ # Extend RunTypes with additional behavior. (See comments for details)
2
3
  module RunTypes
3
4
  # Currently, to find the radius of the curve in the pace table data for a given run time,
4
5
  # we start with a radius equal to that of the midpoint of the X axis for the data when
@@ -22,19 +23,17 @@ module RunbyPace
22
23
  five_k_time = RunbyPace::PaceTime.new(five_k.to_s)
23
24
  pace_data = RunbyPace::PaceData.new(first_pace, last_pace, candidate_divisor)
24
25
  calculated_pace = pace_data.calc(five_k_time)
25
- if !calculated_pace.almost_equals?(golden_pace, allowable_deviation)
26
+ unless calculated_pace.almost_equals?(golden_pace, allowable_deviation)
26
27
  viable_divisor = nil
27
28
  break
28
29
  end
29
30
  viable_divisor = candidate_divisor
30
31
  end
31
32
 
32
- if !viable_divisor.nil?
33
- viable_divisors << viable_divisor
34
- end
33
+ viable_divisors << viable_divisor unless viable_divisor.nil?
35
34
  end
36
35
 
37
- if !viable_divisors.empty?
36
+ unless viable_divisors.empty?
38
37
  # puts viable_divisors
39
38
  midpoint = (viable_divisors.length - 1) / 2
40
39
  return viable_divisors[midpoint]
@@ -1,5 +1,7 @@
1
1
  module RunbyPace
2
2
  module RunTypes
3
+ # Arguably one of the most important run types, the "long run" is harder than an "easy run", but easier than
4
+ # a "distance run". It should remain conversational.
3
5
  class LongRun < RunType
4
6
  attr_reader :slow_pace_data, :fast_pace_data
5
7
 
@@ -18,6 +20,7 @@ module RunbyPace
18
20
  PaceRange.new(fast, slow)
19
21
  end
20
22
 
23
+ # Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
21
24
  class GoldenPaces
22
25
  def self.fast
23
26
  { '14:00': '04:00', '15:00': '04:16', '20:00': '05:31', '25:00': '06:44', '30:00': '07:54', '35:00': '09:01', '40:00': '10:07', '42:00': '10:32' }
@@ -2,6 +2,7 @@ require_relative 'tempo_run'
2
2
 
3
3
  module RunbyPace
4
4
  module RunTypes
5
+ # The "slow tempo" pace roughly equates to your marathon pace.
5
6
  class SlowTempoRun < TempoRun
6
7
  def description
7
8
  'Slow Tempo Run'
@@ -1,5 +1,6 @@
1
1
  module RunbyPace
2
2
  module RunTypes
3
+ # Combines the fast and slow tempo runs into one convenient range of paces
3
4
  class TempoRun < RunType
4
5
  attr_reader :slow_pace_data, :fast_pace_data
5
6
 
@@ -18,6 +19,7 @@ module RunbyPace
18
19
  PaceRange.new(fast, slow)
19
20
  end
20
21
 
22
+ # Used in testing, contains hashes mapping 5K race times with the recommended pace-per-km for this run type.
21
23
  class GoldenPaces
22
24
  def self.fast
23
25
  { '14:00': '03:07', '15:00': '03:20', '20:00': '04:21', '25:00': '05:20', '30:00': '06:19', '35:00': '07:16', '40:00': '08:12', '42:00': '08:35' }
@@ -1,4 +1,5 @@
1
1
  module RunbyPace
2
+ # Base class for ranges of Runby data, e.g. PaceRange, SpeedRange, ...
2
3
  class RunbyRange
3
4
  attr_reader :fast, :slow
4
5
 
@@ -1,6 +1,7 @@
1
1
  require_relative 'runby_range'
2
2
 
3
3
  module RunbyPace
4
+ # Represents a range of speeds, from fast to slow.
4
5
  class SpeedRange < RunbyRange
5
6
  def initialize(fast, slow)
6
7
  raise 'Invalid speed values' unless fast.is_a?(Numeric) && slow.is_a?(Numeric)
@@ -8,6 +9,7 @@ module RunbyPace
8
9
  @slow = slow.round(2)
9
10
  end
10
11
 
12
+ # Create a new speed range from an existing pace range.
11
13
  def self.from_pace_range(pace_range)
12
14
  fast = RunbyPace::RunMath.convert_pace_to_speed pace_range.fast
13
15
  slow = RunbyPace::RunMath.convert_pace_to_speed pace_range.slow
@@ -1,3 +1,3 @@
1
1
  module RunbyPace
2
- VERSION = "0.2.#{`git rev-list --count HEAD`}"
2
+ VERSION = "0.2.#{`git rev-list --count HEAD`}".freeze
3
3
  end
data/runby_pace.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Ty Walls']
10
10
  spec.email = ['tygerbytes@users.noreply.github.com']
11
11
 
12
- spec.summary = %q(Runby Pace is the core logic which simplifies the calculation of target paces used by track and distance runners.)
12
+ spec.summary = 'Runby Pace is the core logic which simplifies the calculation of target paces used by track and distance runners.'
13
13
  spec.homepage = 'https://github.com/tygerbytes/runby-pace'
14
14
  spec.license = 'MIT'
15
15
 
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.72
4
+ version: 0.2.73
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-10 00:00:00.000000000 Z
11
+ date: 2016-08-11 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: 3bc041f857bfd2ebbfa92367f9f7ecd0a3502f4a
100
+ commit-hash: e0969155c9dce3802aaba44d908aa7e3efda7d17
101
101
  post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths: