Class: Interfacets::Client::Channels::Timer::Builder
- Inherits:
-
Object
- Object
- Interfacets::Client::Channels::Timer::Builder
- Defined in:
- lib/interfacets/client/channels/timer.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
readonly
Returns the value of attribute callbacks.
-
#event ⇒ Object
readonly
Returns the value of attribute event.
Instance Method Summary collapse
- #callback(in_ms:, &block) ⇒ Object
- #flush_event ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
14 15 16 17 |
# File 'lib/interfacets/client/channels/timer.rb', line 14 def initialize @event = {} @callbacks = {} end |
Instance Attribute Details
#callbacks ⇒ Object (readonly)
Returns the value of attribute callbacks.
12 13 14 |
# File 'lib/interfacets/client/channels/timer.rb', line 12 def callbacks @callbacks end |
#event ⇒ Object (readonly)
Returns the value of attribute event.
12 13 14 |
# File 'lib/interfacets/client/channels/timer.rb', line 12 def event @event end |
Instance Method Details
#callback(in_ms:, &block) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/interfacets/client/channels/timer.rb', line 23 def callback(in_ms:, &block) id = SecureRandom.uuid event[:ms] = in_ms event[:response] = { id: } callbacks[id] = block end |
#flush_event ⇒ Object
19 20 21 |
# File 'lib/interfacets/client/channels/timer.rb', line 19 def flush_event @event.tap { @event = {} } end |