Class: Raktr::Tasks::Periodic
- Inherits:
-
Persistent
- Object
- Base
- Persistent
- Raktr::Tasks::Periodic
- Defined in:
- lib/raktr/tasks/periodic.rb
Overview
Direct Known Subclasses
Instance Attribute Summary collapse
- #interval ⇒ Float readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#call(*args) ⇒ Object?
Return value of the configured task or ‘nil` if it’s not time yet.
-
#initialize(interval, &task) ⇒ Periodic
constructor
A new instance of Periodic.
Methods inherited from Base
Constructor Details
#initialize(interval, &task) ⇒ Periodic
Returns a new instance of Periodic.
25 26 27 28 29 30 31 32 33 |
# File 'lib/raktr/tasks/periodic.rb', line 25 def initialize( interval, &task ) interval = interval.to_f fail ArgumentError, 'Interval needs to be greater than 0.' if interval <= 0 super( &task ) @interval = interval calculate_next end |
Instance Attribute Details
#interval ⇒ Float (readonly)
20 21 22 |
# File 'lib/raktr/tasks/periodic.rb', line 20 def interval @interval end |
Instance Method Details
#call(*args) ⇒ Object?
Return value of the configured task or ‘nil` if it’s not time yet.
38 39 40 41 42 43 |
# File 'lib/raktr/tasks/periodic.rb', line 38 def call( *args ) return if !call? calculate_next super( *args ) end |