class Runby::GoldenPaceSet
Maps a set of 5K race times with their pre-calculated pace recommendations. This is useful in testing as well as defining the fastest and slowest supported 5K times. GoldenPaceSet
could conceivably be used to pre-compute a large number of recommended paces,
thus reducing runtime CPU overhead.
Constants
- FASTEST_5K
The fastest 5K time supported by RunbyPace
- SLOWEST_5K
The slowest 5K time supported by RunbyPace
Attributes
paces[R]
Public Class Methods
new(paces_hash)
click to toggle source
@param [Hash] paces_hash is a hash mapping 5K time symbols to times, represented as strings. An example paces_hash is {'14:00':'4:00', '15:00':'4:55'}
# File lib/runby_pace/golden_pace_set.rb, line 22 def initialize(paces_hash) @paces = {} paces_hash.each { |five_k_time, recommended_pace| @paces[five_k_time.to_sym] = Pace.new(recommended_pace) } end
new_from_endpoints(fastest, slowest)
click to toggle source
Creates and returns a new GoldenPaceSet
with only two entries
# File lib/runby_pace/golden_pace_set.rb, line 46 def self.new_from_endpoints(fastest, slowest) GoldenPaceSet.new(FASTEST_5K => fastest, SLOWEST_5K => slowest) end
Public Instance Methods
each() { |h, v| ... }
click to toggle source
# File lib/runby_pace/golden_pace_set.rb, line 27 def each @paces.each do |h, v| yield h, v end end
first()
click to toggle source
Returns first/fastest recommended pace in the set
# File lib/runby_pace/golden_pace_set.rb, line 34 def first @paces[FASTEST_5K] end
Also aliased as: fastest
last()
click to toggle source
Return the last/slowest recommended pace in the set
# File lib/runby_pace/golden_pace_set.rb, line 40 def last @paces[SLOWEST_5K] end
Also aliased as: slowest