Class: ClockworkMocks::ClockworkTask
- Inherits:
-
Object
- Object
- ClockworkMocks::ClockworkTask
- Defined in:
- lib/clockwork_mocks/clockwork_task.rb
Instance Attribute Summary collapse
-
#due ⇒ Object
readonly
Returns the value of attribute due.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(interval, name, hash, block) ⇒ ClockworkTask
constructor
A new instance of ClockworkTask.
- #perform(handler = nil) ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(interval, name, hash, block) ⇒ ClockworkTask
Returns a new instance of ClockworkTask.
5 6 7 8 9 10 11 12 |
# File 'lib/clockwork_mocks/clockwork_task.rb', line 5 def initialize(interval, name, hash, block) @interval = interval @name = name @hash = hash || {} @block = block @due = calc_due end |
Instance Attribute Details
#due ⇒ Object (readonly)
Returns the value of attribute due.
28 29 30 |
# File 'lib/clockwork_mocks/clockwork_task.rb', line 28 def due @due end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/clockwork_mocks/clockwork_task.rb', line 28 def name @name end |
Instance Method Details
#perform(handler = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/clockwork_mocks/clockwork_task.rb', line 19 def perform(handler = nil) if @block @block.call elsif handler handler.call(@name, Time.now) end @due = calc_due end |
#reset! ⇒ Object
14 15 16 17 |
# File 'lib/clockwork_mocks/clockwork_task.rb', line 14 def reset! @due = Time.now @due = calc_due end |