Class: Runby::SpeedRange
- Inherits:
-
RunbyRange
- Object
- RunbyRange
- Runby::SpeedRange
- Defined in:
- lib/runby_pace/speed_range.rb
Overview
Represents a range of speeds, from fast to slow.
Instance Attribute Summary
Attributes inherited from RunbyRange
Class Method Summary collapse
-
.from_pace_range(pace_range) ⇒ Object
Create a new speed range from an existing pace range.
Instance Method Summary collapse
-
#initialize(fast, slow) ⇒ SpeedRange
constructor
A new instance of SpeedRange.
Methods inherited from RunbyRange
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
Create a new speed range from an existing pace range.
13 14 15 16 17 18 |
# File 'lib/runby_pace/speed_range.rb', line 13 def self.from_pace_range(pace_range) # TODO: We need a Speed class with Distance_units included fast = Runby::RunMath.convert_pace_to_speed pace_range.fast.time slow = Runby::RunMath.convert_pace_to_speed pace_range.slow.time SpeedRange.new fast, slow end |