lib/runby_pace/pace.rb in runby_pace-0.61.153 vs lib/runby_pace/pace.rb in runby_pace-0.61.154
- old
+ new
@@ -5,14 +5,17 @@
class Pace
include Comparable
attr_reader :time, :distance
+ def self.new(time_or_pace, distance = '1K')
+ return time_or_pace if time_or_pace.is_a? Pace
+ super
+ end
+
def initialize(time_or_pace, distance = '1K')
case time_or_pace
- when Pace
- init_from_clone time_or_pace
when RunbyTime
init_from_time time_or_pace, distance
when String
init_from_string time_or_pace, distance
else
@@ -125,15 +128,9 @@
distance_covered = Runby::Distance.new(@distance.uom, 1 / divisor)
distance_covered
end
private
-
- def init_from_clone(other_pace)
- raise "#{other_pace} is not a Runby::Pace" unless other_pace.is_a? Pace
- @time = other_pace.time
- @distance = other_pace.distance
- end
def init_from_string(string, distance = '1K')
pace = Pace.try_parse(string)
if pace[:pace]
@time = pace[:pace].time