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)



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

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   = Adhearsion::Rayo::Component::Record.new options
end

Instance Attribute Details

#record_componentObject

Returns the value of attribute record_component



14
15
16
# File 'lib/adhearsion/call_controller/record.rb', line 14

def record_component
  @record_component
end

#stopper_componentObject

Returns the value of attribute stopper_component



14
15
16
# File 'lib/adhearsion/call_controller/record.rb', line 14

def stopper_component
  @stopper_component
end

Instance Method Details

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

Set a callback to be executed when recording completes

Yields:



58
59
60
# File 'lib/adhearsion/call_controller/record.rb', line 58

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

#runObject

Execute the recorder

Returns:

  • nil



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

def run
  execute_stopper
  execute_recording
  terminate_stopper
  nil
end