lib/rufus/otime.rb in rufus-scheduler-1.0.7 vs lib/rufus/otime.rb in rufus-scheduler-1.0.8
- old
+ new
@@ -334,9 +334,23 @@
end
h
end
+ #
+ # Ensures that a duration is a expressed as a Float instance.
+ #
+ # duration_to_f("10s")
+ #
+ # will yield 10.0
+ #
+ def Rufus.duration_to_f (s)
+
+ return s if s.kind_of?(Float)
+ return parse_time_string(s) if s.kind_of?(String)
+ Float(s.to_s)
+ end
+
protected
DURATIONS2M = [
[ "y", 365 * 24 * 3600 ],
[ "M", 30 * 24 * 3600 ],