Class: Punchblock::Translator::Asterisk::Component::ComposedPrompt

Inherits:
Component
  • Object
show all
Includes:
StopByRedirect, InputComponent
Defined in:
lib/punchblock/translator/asterisk/component/composed_prompt.rb

Instance Attribute Summary

Attributes inherited from Component

#call, #call_id, #id

Instance Method Summary collapse

Methods included from StopByRedirect

#execute_command, #stop_by_redirect

Methods included from InputComponent

#execute_command, #match, #noinput, #nomatch

Methods inherited from Component

#call_ended, #execute_command, #initialize, #logger_id, #send_complete_event, #send_event, #setup

Constructor Details

This class inherits a constructor from Punchblock::Translator::Asterisk::Component::Component

Instance Method Details

#executeObject


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/punchblock/translator/asterisk/component/composed_prompt.rb', line 11

def execute
  validate
  output_command.request!
  setup_dtmf_recognizer

  @output_incomplete = true

  @output_component = Output.new(output_command, @call)
  call.register_component @output_component
  fut = Celluloid::Future.new { @output_component.execute }

  case @output_command.response
  when Ref
    send_ref
  else
    set_node_response @output_command.response
  end

  if @component_node.barge_in
    @barged = false
    register_dtmf_event_handler
    fut.value # Block until output is complete before starting timers
    @output_incomplete = false
    start_timers unless @barged
  else
    fut.value # Block until output is complete before allowing input
    register_dtmf_event_handler
    start_timers
  end
end

#output_commandObject


50
51
52
# File 'lib/punchblock/translator/asterisk/component/composed_prompt.rb', line 50

def output_command
  @output_command ||= @component_node.output
end

#process_dtmf(digit) ⇒ Object


42
43
44
45
46
47
48
# File 'lib/punchblock/translator/asterisk/component/composed_prompt.rb', line 42

def process_dtmf(digit)
  if @component_node.barge_in && @output_incomplete
    @output_component.stop_by_redirect Punchblock::Event::Complete::Stop.new
    @barged = true
  end
  super
end