Class: CloudwatchChrono::Schedule
- Inherits:
-
Chrono::Schedule
- Object
- Chrono::Schedule
- CloudwatchChrono::Schedule
- Defined in:
- lib/cloudwatch_chrono/schedule.rb
Instance Method Summary collapse
- #days? ⇒ Boolean
-
#initialize(source) ⇒ Schedule
constructor
A new instance of Schedule.
- #last_day? ⇒ Boolean
- #latest_weekday ⇒ Object
-
#ordered_weekday ⇒ Object
e.g.
- #wdays ⇒ Object
- #wdays? ⇒ Boolean
- #years ⇒ Object
Constructor Details
#initialize(source) ⇒ Schedule
Returns a new instance of Schedule.
5 6 7 8 9 10 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 5 def initialize(source) if %r<\A[ \t]*(?:(?<field>\S+)[ \t]+){5}\g<field>[ \t]*\z> !~ source raise Chrono::Fields::Base::InvalidField.new('invalid source', source) end @source = source end |
Instance Method Details
#days? ⇒ Boolean
20 21 22 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 20 def days? !%w[* ?].include?(fields[2]) end |
#last_day? ⇒ Boolean
28 29 30 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 28 def last_day? fields[2] == 'L' end |
#latest_weekday ⇒ Object
32 33 34 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 32 def latest_weekday fields[2].slice(/\A(\d+)W\z/, 1) end |
#ordered_weekday ⇒ Object
e.g. 3#2 means the second Tuesday and returns [3, 2]
37 38 39 40 41 42 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 37 def ordered_weekday m = fields[2].match(/\A([0-6])#([1-5])\z/) if m m[1, 2].map(&:to_i) end end |
#wdays ⇒ Object
12 13 14 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 12 def wdays Fields::Wday.new(fields[4]).to_a end |
#wdays? ⇒ Boolean
24 25 26 |
# File 'lib/cloudwatch_chrono/schedule.rb', line 24 def wdays? !%w[* ?].include?(fields[4]) end |