Class: Cronline::Cron
- Inherits:
-
Object
- Object
- Cronline::Cron
- Defined in:
- lib/cronline/cron.rb
Instance Attribute Summary collapse
-
#days ⇒ Object
readonly
Returns the value of attribute days.
-
#hours ⇒ Object
readonly
Returns the value of attribute hours.
-
#minutes ⇒ Object
readonly
Returns the value of attribute minutes.
-
#months ⇒ Object
readonly
Returns the value of attribute months.
-
#seconds ⇒ Object
readonly
Returns the value of attribute seconds.
-
#years ⇒ Object
readonly
Returns the value of attribute years.
Instance Method Summary collapse
-
#initialize(cron_expression) ⇒ Cron
constructor
A new instance of Cron.
- #test?(time) ⇒ Boolean
- #test_up_to_hours?(time) ⇒ Boolean
Constructor Details
#initialize(cron_expression) ⇒ Cron
Returns a new instance of Cron.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cronline/cron.rb', line 12 def initialize(cron_expression) @seconds = CronSeconds.new(cron_expression) @minutes = CronMinutes.new(cron_expression) @hours = CronHours.new(cron_expression) @months = CronMonths.new(cron_expression) @years = CronYears.new(cron_expression) cron_days_of_month = CronDaysOfMonth.new(cron_expression) cron_days_of_week = CronDaysOfWeek.new(cron_expression) if (cron_days_of_month).active? && (cron_days_of_week).active? fail 'Only one days field is allowed' elsif cron_days_of_week.active? @days = cron_days_of_week elsif cron_days_of_month.active? @days = cron_days_of_month else fail 'One day field is required' end end |
Instance Attribute Details
#days ⇒ Object (readonly)
Returns the value of attribute days.
3 4 5 |
# File 'lib/cronline/cron.rb', line 3 def days @days end |
#hours ⇒ Object (readonly)
Returns the value of attribute hours.
3 4 5 |
# File 'lib/cronline/cron.rb', line 3 def hours @hours end |
#minutes ⇒ Object (readonly)
Returns the value of attribute minutes.
3 4 5 |
# File 'lib/cronline/cron.rb', line 3 def minutes @minutes end |
#months ⇒ Object (readonly)
Returns the value of attribute months.
3 4 5 |
# File 'lib/cronline/cron.rb', line 3 def months @months end |
#seconds ⇒ Object (readonly)
Returns the value of attribute seconds.
3 4 5 |
# File 'lib/cronline/cron.rb', line 3 def seconds @seconds end |
#years ⇒ Object (readonly)
Returns the value of attribute years.
3 4 5 |
# File 'lib/cronline/cron.rb', line 3 def years @years end |
Instance Method Details
#test?(time) ⇒ Boolean
33 34 35 36 |
# File 'lib/cronline/cron.rb', line 33 def test?(time) @years.test?(time) && @months.test?(time) && @days.test?(time) && @hours.test?(time) && @minutes.test?(time) && @seconds.test?(time) end |
#test_up_to_hours?(time) ⇒ Boolean
38 39 40 41 |
# File 'lib/cronline/cron.rb', line 38 def test_up_to_hours?(time) @years.test?(time) && @months.test?(time) && @days.test?(time) && @hours.test?(time) end |