lib/fugit/nat.rb in fugit-0.9.4 vs lib/fugit/nat.rb in fugit-0.9.5
- old
+ new
@@ -30,10 +30,14 @@
#
module Nat
def self.parse(s)
+ return s if s.is_a?(Fugit::Cron) || s.is_a?(Fugit::Duration)
+
+ return nil unless s.is_a?(String)
+
#p s; Raabro.pp(Parser.parse(s, debug: 3))
a = Parser.parse(s)
#p a
return nil unless a
@@ -41,9 +45,14 @@
if a.include?([ :flag, 'every' ])
parse_cron(a)
else
nil
end
+ end
+
+ def self.do_parse(s)
+
+ parse(s) || fail(ArgumentError.new("could not parse a nat #{s.inspect}"))
end
def self.parse_cron(a)
h = { min: nil, hou: [], dom: [ nil ], mon: [ nil ], dow: [ nil ] }