lib/rufus/scheduler/util.rb in rufus-scheduler-3.1.9 vs lib/rufus/scheduler/util.rb in rufus-scheduler-3.1.10
- old
+ new
@@ -36,11 +36,11 @@
opts[:no_error] = true
parse_cron(o, opts) ||
parse_in(o, opts) || # covers 'every' schedule strings
parse_at(o, opts) ||
- raise(ArgumentError.new("couldn't parse \"#{o}\""))
+ fail(ArgumentError.new("couldn't parse \"#{o}\""))
end
def self.parse_in(o, opts={})
o.is_a?(String) ? parse_duration(o, opts) : o
@@ -51,30 +51,30 @@
Rufus::Scheduler::ZoTime.parse(o, opts).time
rescue StandardError => se
return nil if opts[:no_error]
- raise se
+ fail se
end
def self.parse_cron(o, opts)
CronLine.new(o)
rescue ArgumentError => ae
return nil if opts[:no_error]
- raise ae
+ fail ae
end
def self.parse_to_time(o)
t = o
t = parse(t) if t.is_a?(String)
t = Time.now + t if t.is_a?(Numeric)
- raise ArgumentError.new(
+ fail ArgumentError.new(
"cannot turn #{o.inspect} to a point in time, doesn't make sense"
) unless t.is_a?(Time)
t
end
@@ -130,11 +130,11 @@
return 0.0 if string == ''
m = string.match(/^(-?)([\d\.#{DURATION_LETTERS}]+)$/)
return nil if m.nil? && opts[:no_error]
- raise ArgumentError.new("cannot parse '#{string}'") if m.nil?
+ fail ArgumentError.new("cannot parse '#{string}'") if m.nil?
mod = m[1] == '-' ? -1.0 : 1.0
val = 0.0
s = m[2]
@@ -148,12 +148,10 @@
elsif s.match(/^\d*\.\d*$/)
val += s.to_f
elsif opts[:no_error]
return nil
else
- raise ArgumentError.new(
- "cannot parse '#{string}' (especially '#{s}')"
- )
+ fail ArgumentError.new("cannot parse '#{string}' (especially '#{s}')")
end
break unless m && m[3]
s = m[3]
end