Class: Topaz::Clock::EventTrigger
- Inherits:
-
Object
- Object
- Topaz::Clock::EventTrigger
- Defined in:
- lib/topaz/clock.rb
Overview
Trigger clock events
Instance Method Summary collapse
-
#initialize ⇒ EventTrigger
constructor
A new instance of EventTrigger.
-
#stop(&callback) ⇒ Array<Proc>
Pass in a callback which will stop the clock if it evaluates to true.
-
#stop? ⇒ Boolean
Should the stop event be triggered?.
Constructor Details
#initialize ⇒ EventTrigger
Returns a new instance of EventTrigger.
95 96 97 |
# File 'lib/topaz/clock.rb', line 95 def initialize @stop = [] end |
Instance Method Details
#stop(&callback) ⇒ Array<Proc>
Pass in a callback which will stop the clock if it evaluates to true
102 103 104 105 106 107 108 |
# File 'lib/topaz/clock.rb', line 102 def stop(&callback) if block_given? @stop.clear @stop << callback end @stop end |
#stop? ⇒ Boolean
Should the stop event be triggered?
112 113 114 |
# File 'lib/topaz/clock.rb', line 112 def stop? !@stop.nil? && @stop.any?(&:call) end |