Class: When::Cron
- Inherits:
-
Object
- Object
- When::Cron
- Defined in:
- lib/when-cron/cron/cron.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(time) ⇒ Object
-
#initialize(cron) ⇒ Cron
constructor
A new instance of Cron.
- #parse(string) ⇒ Object
Constructor Details
#initialize(cron) ⇒ Cron
Returns a new instance of Cron.
12 13 14 |
# File 'lib/when-cron/cron/cron.rb', line 12 def initialize(cron) parse(cron) end |
Class Method Details
.valid?(cron) ⇒ Boolean
3 4 5 6 7 8 9 10 |
# File 'lib/when-cron/cron/cron.rb', line 3 def self.valid?(cron) begin new(cron) rescue When::CronPart::InvalidString return false end true end |
Instance Method Details
#==(time) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/when-cron/cron/cron.rb', line 16 def ==(time) matches = [] matches << (@minute == time.min) matches << (@hour == time.hour) matches << (@day == time.day) matches << (@month == time.month) matches << (@wday == time.wday) matches.all? end |
#parse(string) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/when-cron/cron/cron.rb', line 26 def parse(string) strings = string.split(' ') @minute = CronPart.new(strings[0]) @hour = CronPart.new(strings[1]) @day = CronPart.new(strings[2]) @month = CronPart.new(strings[3]) @wday = CronPart.new(strings[4]) end |