lib/fugit/cron.rb in fugit-1.1.2 vs lib/fugit/cron.rb in fugit-1.1.3

- old
+ new

@@ -26,11 +26,10 @@ def parse(s) return s if s.is_a?(self) - original = s s = SPECIALS[s] || s return nil unless s.is_a?(String) #p s; Raabro.pp(Parser.parse(s, debug: 3), colors: true) @@ -92,12 +91,12 @@ def inc_day; inc((24 - @t.hour) * 3600 - @t.min * 60 - @t.sec); end def inc_hour; inc((60 - @t.min) * 60 - @t.sec); end def inc_min; inc(60 - @t.sec); end def inc_sec(seconds) - if s = seconds.find { |s| s > @t.sec } - inc(s - @t.sec) + if sec = seconds.find { |s| s > @t.sec } + inc(sec - @t.sec) else inc(60 - @t.sec + seconds.first) end end @@ -121,11 +120,11 @@ def weekday_match?(nt) return true if @weekdays.nil? - wd, hsh = @weekdays.find { |wd, hsh| wd == nt.wday } + wd, hsh = @weekdays.find { |d, _| d == nt.wday } return false unless wd return true if hsh.nil? phsh, nhsh = nt.wday_in_month @@ -326,40 +325,41 @@ arr.uniq! arr.sort! end - def determine_seconds(a) - @seconds = (a || [ 0 ]).inject([]) { |a, r| a.concat(expand(0, 59, r)) } + def determine_seconds(arr) + @seconds = (arr || [ 0 ]).inject([]) { |a, s| a.concat(expand(0, 59, s)) } compact(:@seconds) end - def determine_minutes(a) - @minutes = a.inject([]) { |a, r| a.concat(expand(0, 59, r)) } + def determine_minutes(arr) + @minutes = arr.inject([]) { |a, m| a.concat(expand(0, 59, m)) } compact(:@minutes) end - def determine_hours(a) - @hours = a.inject([]) { |a, r| a.concat(expand(0, 23, r)) } - @hours = @hours.collect { |h| h == 24 ? 0 : h } + def determine_hours(arr) + @hours = arr + .inject([]) { |a, h| a.concat(expand(0, 23, h)) } + .collect { |h| h == 24 ? 0 : h } compact(:@hours) end - def determine_monthdays(a) - @monthdays = a.inject([]) { |a, r| a.concat(expand(1, 31, r)) } + def determine_monthdays(arr) + @monthdays = arr.inject([]) { |a, d| a.concat(expand(1, 31, d)) } compact(:@monthdays) end - def determine_months(a) - @months = a.inject([]) { |a, r| a.concat(expand(1, 12, r)) } + def determine_months(arr) + @months = arr.inject([]) { |a, m| a.concat(expand(1, 12, m)) } compact(:@months) end - def determine_weekdays(a) + def determine_weekdays(arr) @weekdays = [] - a.each do |a, z, s, h| # a to z, slash and hash + arr.each do |a, z, s, h| # a to z, slash and hash if h @weekdays << [ a, h ] elsif s ((a || 0)..(z || (a ? a : 6))).step(s < 1 ? 1 : s) .each { |i| @weekdays << [ i ] }