lib/fugit/cron.rb in fugit-1.10.0 vs lib/fugit/cron.rb in fugit-1.10.1

- old
+ new

@@ -318,19 +318,26 @@ t.time.translate(from.zone) end # Used by Fugit::Cron#next and Fugit::Cron#prev # - class CronIterator include ::Enumerable + class CronIterator + include ::Enumerable + attr_reader :cron, :start, :current, :direction + def initialize(cron, direction, start) + @cron = cron @start = start @current = start.dup @direction = direction end + def each + loop do + yield(@current = @cron.send(@direction, @current)) end end end