Class: Chrono::NextTime
- Inherits:
-
Object
- Object
- Chrono::NextTime
- Defined in:
- lib/chrono/next_time.rb
Instance Attribute Summary collapse
-
#now ⇒ Object
readonly
Returns the value of attribute now.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#time ⇒ Object
writeonly
Sets the attribute time.
Instance Method Summary collapse
-
#initialize(options) ⇒ NextTime
constructor
A new instance of NextTime.
- #to_time ⇒ Object
Constructor Details
#initialize(options) ⇒ NextTime
Returns a new instance of NextTime.
10 11 12 13 |
# File 'lib/chrono/next_time.rb', line 10 def initialize() @now = [:now] @source = [:source] end |
Instance Attribute Details
#now ⇒ Object (readonly)
Returns the value of attribute now.
6 7 8 |
# File 'lib/chrono/next_time.rb', line 6 def now @now end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'lib/chrono/next_time.rb', line 6 def source @source end |
#time=(value) ⇒ Object
Sets the attribute time
8 9 10 |
# File 'lib/chrono/next_time.rb', line 8 def time=(value) @time = value end |
Instance Method Details
#to_time ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/chrono/next_time.rb', line 15 def to_time # the longest cycle is 4 years (leap year) # Note that the combination of day-month and wday is OR max_time = time + (365 * 3 + 366).days while @time < max_time case when !scheduled_in_this_month? carry_month when !scheduled_in_this_day? carry_day when !scheduled_in_this_hour? carry_hour when !scheduled_in_this_minute? carry_minute else return @time end end raise ArgumentError, "invalid cron string '#{@source}'" end |