Class: Tuile::FakeEventQueue::FakeTicker
- Inherits:
-
Object
- Object
- Tuile::FakeEventQueue::FakeTicker
- Defined in:
- lib/tuile/fake_event_queue.rb
Overview
Handle returned by #tick. Mirrors the public surface of EventQueue::Ticker (‘cancel`, `cancelled?`) but does not auto-fire —the host Tuile::FakeEventQueue drives firing via #tick_once.
Instance Method Summary collapse
-
#cancel ⇒ void
Marks the ticker cancelled.
-
#cancelled? ⇒ Boolean
True once #cancel has been called.
-
#fire ⇒ void
Invokes the user block with the current tick counter, then advances.
-
#initialize(block) ⇒ FakeTicker
constructor
A new instance of FakeTicker.
Constructor Details
#initialize(block) ⇒ FakeTicker
Returns a new instance of FakeTicker.
70 71 72 73 74 |
# File 'lib/tuile/fake_event_queue.rb', line 70 def initialize(block) @block = block @tick = 0 @cancelled = false end |
Instance Method Details
#cancel ⇒ void
This method returns an undefined value.
Marks the ticker cancelled. Idempotent. Subsequent #fire calls are no-ops; Tuile::FakeEventQueue#tick_once also prunes the ticker on its next pass.
83 84 85 |
# File 'lib/tuile/fake_event_queue.rb', line 83 def cancel @cancelled = true end |
#cancelled? ⇒ Boolean
Returns true once #cancel has been called.
77 |
# File 'lib/tuile/fake_event_queue.rb', line 77 def cancelled? = @cancelled |
#fire ⇒ void
This method returns an undefined value.
Invokes the user block with the current tick counter, then advances. No-op when #cancelled?. Typically driven by Tuile::FakeEventQueue#tick_once; safe to call directly from a test that wants to drive a single ticker.
92 93 94 95 96 97 |
# File 'lib/tuile/fake_event_queue.rb', line 92 def fire return if @cancelled @block.call(@tick) @tick += 1 end |