class TabKeeper::Weekly
Constants
- DAY_VALUES
Order matters here - it must match the ordering used by cron (i.e. 0 = Sunday)
- HOUR_VALUES
- MINUTE_VALUES
Attributes
day[R]
hour[R]
min[R]
Public Class Methods
new(day: nil, hour: nil, min: 0)
click to toggle source
# File lib/tab_keeper/weekly.rb, line 8 def initialize(day: nil, hour: nil, min: 0) @day = day @hour = hour @min = min verify! end
Public Instance Methods
to_s()
click to toggle source
# File lib/tab_keeper/weekly.rb, line 15 def to_s "#{min} #{hour} * * #{day_index}" end
Private Instance Methods
day_index()
click to toggle source
# File lib/tab_keeper/weekly.rb, line 23 def day_index return day if day.is_a?(Fixnum) DAY_VALUES.index(day) end
verify!()
click to toggle source
# File lib/tab_keeper/weekly.rb, line 28 def verify! unless MINUTE_VALUES.include?(min) raise ArgumentError, "min must be between 0 and 59" end unless HOUR_VALUES.include?(hour) raise ArgumentError, "hour must be between 0 and 23" end return if DAY_VALUES.include?(day) || (day.is_a?(Fixnum) && DAY_VALUES[day]) raise ArgumentError, "day must be between 0 and 6, or a symbol day name" end