Class: CronTab::Field
- Inherits:
-
Object
- Object
- CronTab::Field
- Defined in:
- lib/cron_tab.rb
Instance Attribute Summary collapse
-
#every ⇒ Object
Returns the value of attribute every.
-
#range ⇒ Object
Returns the value of attribute range.
Instance Method Summary collapse
- #===(rhs) ⇒ Object
-
#initialize(r, e) ⇒ Field
constructor
A new instance of Field.
- #nextof(now) ⇒ Object
Constructor Details
#initialize(r, e) ⇒ Field
Returns a new instance of Field.
118 119 120 121 |
# File 'lib/cron_tab.rb', line 118 def initialize(r, e) self.range = r self.every = e end |
Instance Attribute Details
#every ⇒ Object
Returns the value of attribute every.
116 117 118 |
# File 'lib/cron_tab.rb', line 116 def every @every end |
#range ⇒ Object
Returns the value of attribute range.
116 117 118 |
# File 'lib/cron_tab.rb', line 116 def range @range end |
Instance Method Details
#===(rhs) ⇒ Object
123 124 125 126 127 |
# File 'lib/cron_tab.rb', line 123 def ===(rhs) b = true b = b && ( (rhs - range.first) % every == 0 ) b = b && ( range === rhs ) end |
#nextof(now) ⇒ Object
129 130 131 132 133 134 135 136 137 |
# File 'lib/cron_tab.rb', line 129 def nextof(now) if now < range.first then nextof(range.first) elsif range.last < now || (range.exclude_end? && range.last <= now) then nil else now + ( (now - range.first) % every ) end end |