Sha256: 4e87b771e70fc136eefa2622ee2ae7a717ea41463e615bb1eb08f4ef3bde342a
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
module Chrono class Schedule attr_reader :source TABLE = { '@yearly' => %w"0 0 1 1 *", '@annually' => %w"0 0 1 1 *", '@monthly' => %w"0 0 1 * *", '@weekly' => %w"0 0 * * 0", '@daily' => %w"0 0 * * *", '@hourly' => %w"0 * * * *", } def initialize(source) if @fields = TABLE[source] elsif %r<\A[ \t]*(?:(?<field>\S+)[ \t]+){4}\g<field>[ \t]*\z> !~ source raise Chrono::Fields::Base::InvalidField.new('invalid source', source) end @source = source end def minutes Fields::Minute.new(fields[0]).to_a end def hours Fields::Hour.new(fields[1]).to_a end def days Fields::Day.new(fields[2]).to_a end def months Fields::Month.new(fields[3]).to_a end def wdays Fields::Wday.new(fields[4]).to_a end def days? fields[2] != '*' end def wdays? fields[4] != '*' end def last_day_of_month? fields[2] == 'L' end private def fields @fields ||= source.split(" ") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chrono-0.6.0 | lib/chrono/schedule.rb |