lib/zhong/at.rb in zhong-0.1.0 vs lib/zhong/at.rb in zhong-0.1.1
- old
+ new
@@ -41,10 +41,15 @@
end
def self.parse(at, grace: 0)
return unless at
+ # TODO: refactor this mess
+ if at.respond_to?(:each)
+ return MultiAt.new(at.map { |a| parse(a, grace: grace) })
+ end
+
case at
when /\A([[:alpha:]]+)\s+(.*)\z/
wday = WDAYS[$1]
if wday
@@ -63,8 +68,20 @@
else
fail FailedToParse, at
end
rescue ArgumentError
throw FailedToParse, at
+ end
+ end
+
+ class MultiAt
+ attr_accessor :ats
+
+ def initialize(ats = [])
+ @ats = ats
+ end
+
+ def next_at(time = Time.now)
+ ats.map { |at| at.next_at(time) }.min
end
end
end