Class: Termtter::Task
- Inherits:
-
Object
- Object
- Termtter::Task
- Defined in:
- lib/termtter/task.rb
Instance Attribute Summary collapse
-
#exec_at ⇒ Object
Returns the value of attribute exec_at.
-
#exec_proc ⇒ Object
Returns the value of attribute exec_proc.
-
#interval ⇒ Object
Returns the value of attribute interval.
-
#name ⇒ Object
Returns the value of attribute name.
-
#work ⇒ Object
Returns the value of attribute work.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args = {}, &block) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(args = {}, &block) ⇒ Task
Returns a new instance of Task.
6 7 8 9 10 11 12 |
# File 'lib/termtter/task.rb', line 6 def initialize(args = {}, &block) @name = args[:name] @exec_at = Time.now + (args[:after] || 0) @interval = args[:interval] @exec_proc = block || lambda {} @work = true end |
Instance Attribute Details
#exec_at ⇒ Object
Returns the value of attribute exec_at.
5 6 7 |
# File 'lib/termtter/task.rb', line 5 def exec_at @exec_at end |
#exec_proc ⇒ Object
Returns the value of attribute exec_proc.
5 6 7 |
# File 'lib/termtter/task.rb', line 5 def exec_proc @exec_proc end |
#interval ⇒ Object
Returns the value of attribute interval.
5 6 7 |
# File 'lib/termtter/task.rb', line 5 def interval @interval end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/termtter/task.rb', line 5 def name @name end |
#work ⇒ Object
Returns the value of attribute work.
5 6 7 |
# File 'lib/termtter/task.rb', line 5 def work @work end |
Instance Method Details
#execute ⇒ Object
13 14 15 |
# File 'lib/termtter/task.rb', line 13 def execute exec_proc.call(self) if work end |