Class: Chrono::Schedule
- Inherits:
-
Object
- Object
- Chrono::Schedule
- Defined in:
- lib/chrono/schedule.rb
Constant Summary collapse
- 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 * * * *", }
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #days ⇒ Object
- #days? ⇒ Boolean
- #hours ⇒ Object
-
#initialize(source) ⇒ Schedule
constructor
A new instance of Schedule.
- #last_day_of_month? ⇒ Boolean
- #minutes ⇒ Object
- #months ⇒ Object
- #wdays ⇒ Object
- #wdays? ⇒ Boolean
Constructor Details
#initialize(source) ⇒ Schedule
Returns a new instance of Schedule.
13 14 15 16 17 18 19 |
# File 'lib/chrono/schedule.rb', line 13 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 |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/chrono/schedule.rb', line 3 def source @source end |
Instance Method Details
#days ⇒ Object
29 30 31 |
# File 'lib/chrono/schedule.rb', line 29 def days Fields::Day.new(fields[2]).to_a end |
#days? ⇒ Boolean
41 42 43 |
# File 'lib/chrono/schedule.rb', line 41 def days? fields[2] != '*' end |
#hours ⇒ Object
25 26 27 |
# File 'lib/chrono/schedule.rb', line 25 def hours Fields::Hour.new(fields[1]).to_a end |
#last_day_of_month? ⇒ Boolean
49 50 51 |
# File 'lib/chrono/schedule.rb', line 49 def last_day_of_month? fields[2] == 'L' end |
#minutes ⇒ Object
21 22 23 |
# File 'lib/chrono/schedule.rb', line 21 def minutes Fields::Minute.new(fields[0]).to_a end |
#months ⇒ Object
33 34 35 |
# File 'lib/chrono/schedule.rb', line 33 def months Fields::Month.new(fields[3]).to_a end |
#wdays ⇒ Object
37 38 39 |
# File 'lib/chrono/schedule.rb', line 37 def wdays Fields::Wday.new(fields[4]).to_a end |
#wdays? ⇒ Boolean
45 46 47 |
# File 'lib/chrono/schedule.rb', line 45 def wdays? fields[4] != '*' end |