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 collapse

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

Constants inherited from RayoNode

RayoNode::InvalidNodeError

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #component_id, #connection, #domain, #original_component, #target_call_id, #target_mixer_name

Class Method Summary collapse

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=, #write_attr

Methods inherited from RayoNode

class_from_registration, #eql?, import, #inspect, register, #source

Constructor Details

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

Class Method Details

.new(options = {}) ⇒ Command::Record

Creates an Rayo Record command

Examples:

record :text => 'Hello brown cow.'

returns:
  <record xmlns="urn:xmpp:rayo:record:1">Hello brown cow.</record>

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :format (String)

    to use for recording

  • :initial_timeout (Integer)

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

  • :final_timeout (Integer)

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

  • :max_duration (Integer)

    Indicates the maximum duration for the recording.

  • :start_beep (true, false)

    Indicates whether subsequent record will be preceded with a beep.

  • :start_paused (true, false)

    Whether subsequent record will start in PAUSE mode.

Returns:

  • (Command::Record)

    a Rayo “record” command



29
30
31
32
33
# File 'lib/punchblock/component/record.rb', line 29

def self.new(options = {})
  super().tap do |new_node|
    options.each_pair { |k,v| new_node.send :"#{k}=", v }
  end
end

Instance Method Details

#directionSymbol

Returns the direction of media to be recorded.

Returns:

  • (Symbol)

    the direction of media to be recorded.



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

def direction
  read_attr :direction, :to_sym
end

#direction=(direction) ⇒ Object

Parameters:

  • otherthe (#to_s)

    direction of media to be recorded. Can be :duplex, :recv or :send



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

def direction=(direction)
  if direction && !VALID_DIRECTIONS.include?(direction.to_sym)
    raise ArgumentError, "Invalid Direction (#{direction}), use: #{VALID_DIRECTIONS*' '}"
  end
  write_attr :direction, direction
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.



38
39
40
# File 'lib/punchblock/component/record.rb', line 38

def final_timeout
  read_attr :'final-timeout', :to_i
end

#final_timeout=(timeout) ⇒ Object

Parameters:

  • timeout (Integer)

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



45
46
47
# File 'lib/punchblock/component/record.rb', line 45

def final_timeout=(timeout)
  write_attr :'final-timeout', timeout, :to_i
end

#formatString

Returns the codec to use for recording.

Returns:

  • (String)

    the codec to use for recording



52
53
54
# File 'lib/punchblock/component/record.rb', line 52

def format
  read_attr :format
end

#format=(format) ⇒ Object

Parameters:

  • codec (String)

    to use for recording



59
60
61
# File 'lib/punchblock/component/record.rb', line 59

def format=(format)
  write_attr :format, format
end

#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.



66
67
68
# File 'lib/punchblock/component/record.rb', line 66

def initial_timeout
  read_attr :'initial-timeout', :to_i
end

#initial_timeout=(timeout) ⇒ Object

Parameters:

  • timeout (Integer)

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



73
74
75
# File 'lib/punchblock/component/record.rb', line 73

def initial_timeout=(timeout)
  write_attr :'initial-timeout', timeout, :to_i
end

#inspect_attributesObject

:nodoc:



134
135
136
# File 'lib/punchblock/component/record.rb', line 134

def inspect_attributes # :nodoc:
  [:final_timeout, :format, :initial_timeout, :max_duration, :start_beep, :start_paused, :direction] + super
end

#max_durationInteger

Returns Indicates the maximum duration for the recording.

Returns:

  • (Integer)

    Indicates the maximum duration for the recording.



80
81
82
# File 'lib/punchblock/component/record.rb', line 80

def max_duration
  read_attr :'max-duration', :to_i
end

#max_duration=(other) ⇒ Object

Parameters:

  • other (Integer)

    Indicates the maximum duration for the recording.



87
88
89
# File 'lib/punchblock/component/record.rb', line 87

def max_duration=(other)
  write_attr :'max-duration', other, :to_i
end

#pause!Object

Sends an Rayo pause message for the current Record

Raises:



164
165
166
167
168
169
170
# File 'lib/punchblock/component/record.rb', line 164

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



157
158
159
# File 'lib/punchblock/component/record.rb', line 157

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

#recordingPunchblock::Component::Record::Recording

Directly returns the recording for the component

Returns:



201
202
203
# File 'lib/punchblock/component/record.rb', line 201

def recording
  complete_event.recording
end

#recording_uriString

Directly returns the recording URI for the component

Returns:

  • (String)

    The recording URI



209
210
211
# File 'lib/punchblock/component/record.rb', line 209

def recording_uri
  recording.uri
end

#resume!Object

Sends an Rayo resume message for the current Record

Raises:



189
190
191
192
193
194
195
# File 'lib/punchblock/component/record.rb', line 189

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



182
183
184
# File 'lib/punchblock/component/record.rb', line 182

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

#start_beeptrue, false

Returns Indicates whether subsequent record will be preceded with a beep.

Returns:

  • (true, false)

    Indicates whether subsequent record will be preceded with a beep.



94
95
96
# File 'lib/punchblock/component/record.rb', line 94

def start_beep
  read_attr(:'start-beep') == 'true'
end

#start_beep=(sb) ⇒ Object

Parameters:

  • sb (true, false)

    Indicates whether subsequent record will be preceded with a beep.



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

def start_beep=(sb)
  write_attr :'start-beep', sb
end

#start_pausedtrue, false

Returns Whether subsequent record will start in PAUSE mode.

Returns:

  • (true, false)

    Whether subsequent record will start in PAUSE mode.



108
109
110
# File 'lib/punchblock/component/record.rb', line 108

def start_paused
  read_attr(:'start-paused') == 'true'
end

#start_paused=(other) ⇒ Object

Parameters:

  • other (true, false)

    Whether subsequent record will start in PAUSE mode.



115
116
117
# File 'lib/punchblock/component/record.rb', line 115

def start_paused=(other)
  write_attr :'start-paused', other
end