Class: Punchblock::Component::Record

Inherits:
ComponentNode show all
Defined in:
lib/punchblock/component/record.rb

Defined Under Namespace

Classes: Complete, Pause, Recording, Resume

Constant Summary

VALID_DIRECTIONS =
[:duplex, :send, :recv].freeze

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #connection, #original_component

Instance Method Summary collapse

Methods inherited from ComponentNode

#add_event, #complete_event, #complete_event=, #initialize, #register_event_handler, #register_internal_handlers, #response=, #stop!, #stop_action, #trigger_event_handler, #write_action

Methods inherited from Punchblock::CommandNode

#initialize, #response, #response=

Methods inherited from RayoNode

#==, class_from_registration, from_xml, #inherit, #inspect, #rayo_children, register, #source, #to_rayo, #to_xml

Constructor Details

This class inherits a constructor from Punchblock::Component::ComponentNode

Instance Method Details

#directionSymbol

Returns the direction of media to be recorded.

Returns:

  • (Symbol)

    the direction of media to be recorded.



32
# File 'lib/punchblock/component/record.rb', line 32

attribute :direction, Symbol

#direction=(direction) ⇒ Object



33
34
35
36
37
38
# File 'lib/punchblock/component/record.rb', line 33

def direction=(direction)
  if direction && !VALID_DIRECTIONS.include?(direction.to_sym)
    raise ArgumentError, "Invalid Direction (#{direction}), use: #{VALID_DIRECTIONS*' '}"
  end
  super
end

#final_timeoutInteger

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

Returns:

  • (Integer)

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



17
# File 'lib/punchblock/component/record.rb', line 17

attribute :final_timeout, Integer

#formatString

Returns the codec to use for recording

Returns:

  • (String)

    the codec to use for recording



11
# File 'lib/punchblock/component/record.rb', line 11

attribute :format

#initial_timeoutInteger

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

Returns:

  • (Integer)

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



14
# File 'lib/punchblock/component/record.rb', line 14

attribute :initial_timeout, Integer

#max_durationInteger

Returns Indicates the maximum duration for the recording.

Returns:

  • (Integer)

    Indicates the maximum duration for the recording.



20
# File 'lib/punchblock/component/record.rb', line 20

attribute :max_duration, Integer

#mixtrue, false

Returns wether to mix audio down or not

Returns:

  • (true, false)

    wether to mix audio down or not



41
# File 'lib/punchblock/component/record.rb', line 41

attribute :mix, Boolean

#pause!Object

Sends an Rayo pause message for the current Record

Raises:



83
84
85
86
87
88
89
# File 'lib/punchblock/component/record.rb', line 83

def pause!
  raise InvalidActionError, "Cannot pause a Record that is not executing" unless executing?
  pause_action.tap do |action|
    result = write_action action
    paused! if result
  end
end

#pause_actionCommand::Record::Pause

Pauses a running Record

Examples:

record_obj.pause_action.to_xml

returns:
  <pause xmlns="urn:xmpp:rayo:record:1"/>

Returns:

  • (Command::Record::Pause)

    an Rayo pause message for the current Record



76
77
78
# File 'lib/punchblock/component/record.rb', line 76

def pause_action
  Pause.new :component_id => component_id, :target_call_id => target_call_id
end

#rayo_attributesObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/punchblock/component/record.rb', line 43

def rayo_attributes
  {
    'format' => format,
    'initial-timeout' => initial_timeout,
    'final-timeout' => final_timeout,
    'max-duration' => max_duration,
    'start-beep' => start_beep,
    'stop-beep' => start_beep,
    'start-paused' => start_paused,
    'direction' => direction,
    'mix' => mix
  }
end

#recordingPunchblock::Component::Record::Recording

Directly returns the recording for the component

Returns:



120
121
122
# File 'lib/punchblock/component/record.rb', line 120

def recording
  complete_event.recording
end

#recording_uriString

Directly returns the recording URI for the component

Returns:

  • (String)

    The recording URI



128
129
130
# File 'lib/punchblock/component/record.rb', line 128

def recording_uri
  recording.uri
end

#resume!Object

Sends an Rayo resume message for the current Record

Raises:



108
109
110
111
112
113
114
# File 'lib/punchblock/component/record.rb', line 108

def resume!
  raise InvalidActionError, "Cannot resume a Record that is not paused." unless paused?
  resume_action.tap do |action|
    result = write_action action
    resumed! if result
  end
end

#resume_actionCommand::Record::Resume

Create an Rayo resume message for the current Record

Examples:

record_obj.resume_action.to_xml

returns:
  <resume xmlns="urn:xmpp:rayo:record:1"/>

Returns:

  • (Command::Record::Resume)

    an Rayo resume message



101
102
103
# File 'lib/punchblock/component/record.rb', line 101

def resume_action
  Resume.new :component_id => component_id, :target_call_id => target_call_id
end

#start_beeptrue, false

Returns Indicates whether record will be preceded with a beep.

Returns:

  • (true, false)

    Indicates whether record will be preceded with a beep.



23
# File 'lib/punchblock/component/record.rb', line 23

attribute :start_beep, Boolean

#start_pausedtrue, false

Returns Whether subsequent record will start in PAUSE mode.

Returns:

  • (true, false)

    Whether subsequent record will start in PAUSE mode.



29
# File 'lib/punchblock/component/record.rb', line 29

attribute :start_paused, Boolean

#stop_beeptrue, false

Returns Indicates whether record will be followed by a beep.

Returns:

  • (true, false)

    Indicates whether record will be followed by a beep.



26
# File 'lib/punchblock/component/record.rb', line 26

attribute :stop_beep, Boolean