Class: RunbyPace::SpeedRange

Inherits:
RunbyRange show all
Defined in:
lib/runby_pace/speed_range.rb

Instance Attribute Summary

Attributes inherited from RunbyRange

#fast, #slow

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RunbyRange

#to_s

Constructor Details

#initialize(fast, slow) ⇒ SpeedRange

Returns a new instance of SpeedRange.



6
7
8
9
10
# File 'lib/runby_pace/speed_range.rb', line 6

def initialize(fast, slow)
  raise 'Invalid speed values' unless fast.is_a?(Numeric) && slow.is_a?(Numeric)
  @fast = fast.round(2)
  @slow = slow.round(2)
end

Class Method Details

.from_pace_range(pace_range) ⇒ Object



12
13
14
15
16
# File 'lib/runby_pace/speed_range.rb', line 12

def self.from_pace_range(pace_range)
  fast = RunbyPace::RunMath.convert_pace_to_speed pace_range.fast
  slow = RunbyPace::RunMath.convert_pace_to_speed pace_range.slow
  SpeedRange.new fast, slow
end