add equality testing to At
# File lib/clockwork/at.rb, line 38 def initialize(min, hour=NOT_SPECIFIED, wday=NOT_SPECIFIED) @min = min @hour = hour @wday = wday raise ArgumentError unless valid? end
# File lib/clockwork/at.rb, line 12 def self.parse(at) return unless at case at when /^([[:alpha:]]+)\s(.*)$/ if wday = WDAYS[$1] parsed_time = parse($2) parsed_time.wday = wday parsed_time else raise FailedToParse, at end when /^(\d{1,2}):(\d\d)$/ new($2.to_i, $1.to_i) when /^\*{1,2}:(\d\d)$/ new($1.to_i) when /^(\d{1,2}):\*\*$/ new(NOT_SPECIFIED, $1.to_i) else raise FailedToParse, at end rescue ArgumentError raise FailedToParse, at end
# File lib/clockwork/manager_with_database_tasks.rb, line 7 def == other @min == other.min && @hour == other.hour && @wday == other.wday end
# File lib/clockwork/at.rb, line 45 def ready?(t) (@min == NOT_SPECIFIED or t.min == @min) and (@hour == NOT_SPECIFIED or t.hour == @hour) and (@wday == NOT_SPECIFIED or t.wday == @wday) end
# File lib/clockwork/at.rb, line 52 def valid? @min == NOT_SPECIFIED || (0..59).cover?(@min) && @hour == NOT_SPECIFIED || (0..23).cover?(@hour) && @wday == NOT_SPECIFIED || (0..6).cover?(@wday) end