class Clockwork::At
Constants
- NOT_SPECIFIED
- WDAYS
Attributes
hour[RW]
min[RW]
wday[RW]
Public Class Methods
new(min, hour=NOT_SPECIFIED, wday=NOT_SPECIFIED)
click to toggle source
# 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
parse(at)
click to toggle source
# File lib/clockwork/at.rb, line 12 def self.parse(at) return unless at case at when /\A([[:alpha:]]+)\s(.*)\z/ if wday = WDAYS[$1] parsed_time = parse($2) parsed_time.wday = wday parsed_time else raise FailedToParse, at end when /\A(\d{1,2}):(\d\d)\z/ new($2.to_i, $1.to_i) when /\A\*{1,2}:(\d\d)\z/ new($1.to_i) when /\A(\d{1,2}):\*\*\z/ new(NOT_SPECIFIED, $1.to_i) else raise FailedToParse, at end rescue ArgumentError raise FailedToParse, at end
Public Instance Methods
==(other)
click to toggle source
# File lib/clockwork/at.rb, line 51 def == other @min == other.min && @hour == other.hour && @wday == other.wday end
ready?(t)
click to toggle source
# 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
Private Instance Methods
valid?()
click to toggle source
# File lib/clockwork/at.rb, line 56 def valid? @min == NOT_SPECIFIED || (0..59).cover?(@min) && @hour == NOT_SPECIFIED || (0..23).cover?(@hour) && @wday == NOT_SPECIFIED || (0..6).cover?(@wday) end