Class: Interfacets::Client::Channels::Timer::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/interfacets/client/channels/timer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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