Class: Interfacets::Client::Channels::Audio::Builder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Builder

Returns a new instance of Builder.



15
16
17
18
# File 'lib/interfacets/client/channels/audio.rb', line 15

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/audio.rb', line 12

def callbacks
  @callbacks
end

#entity ⇒ Object

Returns the value of attribute entity.



13
14
15
# File 'lib/interfacets/client/channels/audio.rb', line 13

def entity
  @entity
end

#event ⇒ Object (readonly)

Returns the value of attribute event.



12
13
14
# File 'lib/interfacets/client/channels/audio.rb', line 12

def event
  @event
end

Instance Method Details

#flush_event ⇒ Object



20
21
22
# File 'lib/interfacets/client/channels/audio.rb', line 20

def flush_event
  @event.tap { @event = {} }
end

#load_audios(audios, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/interfacets/client/channels/audio.rb', line 29

def load_audios(audios, &block)
  id = SecureRandom.uuid
  @event = {
    id:,
    type: "load",
    payload: audios,
  }
  @callbacks[id] = block
end

#play(sounds, reset_offset: false) ⇒ Object



24
25
26
27
# File 'lib/interfacets/client/channels/audio.rb', line 24

def play(sounds, reset_offset: false)
  event[:type] = "play"
  event[:payload] ||= { sounds:, resetOffset: reset_offset }
end

#request_mic(&block) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/interfacets/client/channels/audio.rb', line 39

def request_mic(&block)
  id = SecureRandom.uuid
  @callbacks[id] = block
  @event = {
    id:,
    type: "request-mic",
    payload: {},
  }
end

#start_recording(&block) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'lib/interfacets/client/channels/audio.rb', line 49

def start_recording(&block)
  id = SecureRandom.uuid
  @callbacks[id] = block
  @event = {
    id:,
    type: "start-record",
    payload: {},
  }
end

#stop_recording(&block) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/interfacets/client/channels/audio.rb', line 59

def stop_recording(&block)
  id = SecureRandom.uuid
  @callbacks[id] = block
  @event = {
    id:,
    type: "stop-record",
    payload: {},
  }
end