Class: Adhearsion::CallController::Record::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/call_controller/record.rb

Overview

Handle a recording

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, options = {}) ⇒ Recorder

Returns a new instance of Recorder.

Parameters:

Options Hash (options):

  • :async (Boolean, Optional)

    Execute asynchronously. Defaults to false

  • :start_beep (Boolean, Optional)

    Indicates whether subsequent record will be preceded with a beep. Default is false.

  • :start_paused (Boolean, Optional)

    Whether subsequent record will start in PAUSE mode. Default is false.

  • :max_duration (String, Optional)

    Indicates the maximum duration (seconds) for a recording.

  • :format (String, Optional)

    File format used during recording.

  • :initial_timeout (String, Optional)

    Controls how long (seconds) the recognizer should wait after the end of the prompt for the caller to speak before sending a Recorder event.

  • :final_timeout (String, Optional)

    Controls the length (seconds) of a period of silence after callers have spoken to conclude they finished.

  • :interruptible (Boolean, Optional)

    Allows the recording to be terminated by any single DTMF key, default is false

  • :direction (Symbol, Optional)

    Controls which sides of the conversation are recorded: :recv (what the caller hears), :send (what the caller said), or :duplex (both)



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/adhearsion/call_controller/record.rb', line 27

def initialize(controller, options = {})
  @controller = controller

  options = prep_options options

  @async = options.delete :async

  interruptible = options.delete :interruptible
  @stopper_component  = interruptible ? setup_stopper(interruptible) : nil
  @record_component   = Punchblock::Component::Record.new options
end

Instance Attribute Details

#record_componentObject

Returns the value of attribute record_component.



12
13
14
# File 'lib/adhearsion/call_controller/record.rb', line 12

def record_component
  @record_component
end

#stopper_componentObject

Returns the value of attribute stopper_component.



12
13
14
# File 'lib/adhearsion/call_controller/record.rb', line 12

def stopper_component
  @stopper_component
end

Instance Method Details

#handle_record_completion {|Punchblock::Event::Complete| ... } ⇒ Object

Set a callback to be executed when recording completes

Yields:

  • (Punchblock::Event::Complete)

    the complete Event for the recording



56
57
58
# File 'lib/adhearsion/call_controller/record.rb', line 56

def handle_record_completion(&block)
  @record_component.register_event_handler Punchblock::Event::Complete, &block
end

#runObject

Execute the recorder

Returns:

  • nil



44
45
46
47
48
49
# File 'lib/adhearsion/call_controller/record.rb', line 44

def run
  execute_stopper
  execute_recording
  terminate_stopper
  nil
end