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.
96 97 98 |
# File 'lib/topaz/clock.rb', line 96 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
103 104 105 106 107 108 109 |
# File 'lib/topaz/clock.rb', line 103 def stop(&callback) if block_given? @stop.clear @stop << callback end @stop end |
#stop? ⇒ Boolean
Should the stop event be triggered?
113 114 115 |
# File 'lib/topaz/clock.rb', line 113 def stop? !@stop.nil? && @stop.any?(&:call) end |