Class: Punchblock::Component::Output

Inherits:
ComponentNode show all
Includes:
HasHeaders
Defined in:
lib/punchblock/component/output.rb

Defined Under Namespace

Classes: Complete, Document, Pause, Resume, Seek, SlowDown, SpeedUp, VolumeDown, VolumeUp

Instance Attribute Summary

Attributes inherited from RayoNode

#client, #connection, #original_component

Instance Method Summary collapse

Methods included from HasHeaders

#headers=, included

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, #inspect, register, #source, #to_rayo, #to_xml

Constructor Details

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

Instance Method Details

#inherit(xml_node) ⇒ Object



78
79
80
81
82
# File 'lib/punchblock/component/output.rb', line 78

def inherit(xml_node)
  document_nodes = xml_node.xpath 'ns:document', ns: self.class.registered_ns
  self.render_documents = document_nodes.to_a.map { |node| Document.from_xml node }
  super
end

#interrupt_onSymbol

Returns input type on which to interrupt output.

Returns:

  • (Symbol)

    input type on which to interrupt output



88
# File 'lib/punchblock/component/output.rb', line 88

attribute :interrupt_on, Symbol

#max_timeInteger

Returns Indicates the maximum amount of time for which the output should be allowed to run before being terminated. Includes repeats.

Returns:

  • (Integer)

    Indicates the maximum amount of time for which the output should be allowed to run before being terminated. Includes repeats.



103
# File 'lib/punchblock/component/output.rb', line 103

attribute :max_time, Integer

#pause!Object

Sends an Rayo pause message for the current Output

Raises:



171
172
173
174
175
176
177
# File 'lib/punchblock/component/output.rb', line 171

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

#pause_actionCommand::Output::Pause

Pauses a running Output

Examples:

output_obj.pause_action.to_xml

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

Returns:

  • (Command::Output::Pause)

    an Rayo pause message for the current Output



164
165
166
# File 'lib/punchblock/component/output.rb', line 164

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

#rayo_attributesObject



108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/punchblock/component/output.rb', line 108

def rayo_attributes
  {
    'voice' => voice,
    'interrupt-on' => interrupt_on,
    'start-offset' => start_offset,
    'start-paused' => start_paused,
    'repeat-interval' => repeat_interval,
    'repeat-times' => repeat_times,
    'max-time' => max_time,
    'renderer' => renderer
  }
end

#rayo_children(root) ⇒ Object



121
122
123
124
125
126
# File 'lib/punchblock/component/output.rb', line 121

def rayo_children(root)
  render_documents.each do |render_document|
    render_document.to_rayo root.parent
  end
  super
end

#render_document=(other) ⇒ Object

Parameters:

  • other (Hash)

Options Hash (other):

  • :content_type (String)

    the document content type

  • :value (String)

    the output doucment

  • :url (String)

    the url from which to fetch the document



137
138
139
# File 'lib/punchblock/component/output.rb', line 137

def render_document=(other)
  self.render_documents = [other].compact
end

#render_documentsDocument

Returns the document to render.

Returns:



129
# File 'lib/punchblock/component/output.rb', line 129

attribute :render_documents, Array[Document], default: []

#rendererString

Returns the rendering engine requested by the component.

Returns:

  • (String)

    the rendering engine requested by the component



106
# File 'lib/punchblock/component/output.rb', line 106

attribute :renderer, String

#repeat_intervalInteger

Returns Indicates the duration of silence that should space repeats of the rendered document.

Returns:

  • (Integer)

    Indicates the duration of silence that should space repeats of the rendered document.



97
# File 'lib/punchblock/component/output.rb', line 97

attribute :repeat_interval, Integer

#repeat_timesInteger

Returns Indicates the number of times the output should be played.

Returns:

  • (Integer)

    Indicates the number of times the output should be played.



100
# File 'lib/punchblock/component/output.rb', line 100

attribute :repeat_times, Integer

#resume!Object

Sends an Rayo resume message for the current Output

Raises:



196
197
198
199
200
201
202
# File 'lib/punchblock/component/output.rb', line 196

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

#resume_actionCommand::Output::Resume

Create an Rayo resume message for the current Output

Examples:

output_obj.resume_action.to_xml

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

Returns:

  • (Command::Output::Resume)

    an Rayo resume message



189
190
191
# File 'lib/punchblock/component/output.rb', line 189

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

#seek!(options = {}) ⇒ Object

Sends a Rayo seek message for the current Output

Raises:



231
232
233
234
235
236
# File 'lib/punchblock/component/output.rb', line 231

def seek!(options = {})
  raise InvalidActionError, "Cannot seek an Output that is already seeking." if seeking?
  seek_action(options).tap do |action|
    write_action action
  end
end

#seek_action(options = {}) ⇒ Command::Output::Seek

Creates an Rayo seek message for the current Output

Examples:

output_obj.seek_action.to_xml

returns:
  <seek xmlns="urn:xmpp:rayo:output:1"/>

Returns:

  • (Command::Output::Seek)

    a Rayo seek message



222
223
224
225
226
# File 'lib/punchblock/component/output.rb', line 222

def seek_action(options = {})
  Seek.new({ :component_id => component_id, :target_call_id => target_call_id }.merge(options)).tap do |s|
    s.original_component = self
  end
end

#slow_down!Object

Sends a Rayo slow down message for the current Output

Raises:



314
315
316
317
318
319
# File 'lib/punchblock/component/output.rb', line 314

def slow_down!
  raise InvalidActionError, "Cannot slow down an Output that is already speeding." unless not_speeding?
  slow_down_action.tap do |action|
    write_action action
  end
end

#slow_down_actionCommand::Output::SlowDown

Creates an Rayo slow down message for the current Output

Examples:

output_obj.slow_down_action.to_xml

returns:
  <speed-down xmlns="urn:xmpp:rayo:output:1"/>

Returns:

  • (Command::Output::SlowDown)

    a Rayo slow down message



305
306
307
308
309
# File 'lib/punchblock/component/output.rb', line 305

def slow_down_action
  SlowDown.new(:component_id => component_id, :target_call_id => target_call_id).tap do |s|
    s.original_component = self
  end
end

#speed_up!Object

Sends a Rayo speed up message for the current Output

Raises:



288
289
290
291
292
293
# File 'lib/punchblock/component/output.rb', line 288

def speed_up!
  raise InvalidActionError, "Cannot speed up an Output that is already speeding." unless not_speeding?
  speed_up_action.tap do |action|
    write_action action
  end
end

#speed_up_actionCommand::Output::SpeedUp

Creates an Rayo speed up message for the current Output

Examples:

output_obj.speed_up_action.to_xml

returns:
  <speed-up xmlns="urn:xmpp:rayo:output:1"/>

Returns:

  • (Command::Output::SpeedUp)

    a Rayo speed up message



279
280
281
282
283
# File 'lib/punchblock/component/output.rb', line 279

def speed_up_action
  SpeedUp.new(:component_id => component_id, :target_call_id => target_call_id).tap do |s|
    s.original_component = self
  end
end

#ssml=(other) ⇒ Object



141
142
143
# File 'lib/punchblock/component/output.rb', line 141

def ssml=(other)
  self.render_documents = [{:value => other}]
end

#start_offsetInteger

Returns Indicates some offset through which the output should be skipped before rendering begins.

Returns:

  • (Integer)

    Indicates some offset through which the output should be skipped before rendering begins.



91
# File 'lib/punchblock/component/output.rb', line 91

attribute :start_offset, Integer

#start_pausedtrue, false

Returns Indicates wether or not the component should be started in a paused state to be resumed at a later time.

Returns:

  • (true, false)

    Indicates wether or not the component should be started in a paused state to be resumed at a later time.



94
# File 'lib/punchblock/component/output.rb', line 94

attribute :start_paused, Boolean

#voiceString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



85
# File 'lib/punchblock/component/output.rb', line 85

attribute :voice, String

#volume_down!Object

Sends a Rayo volume down message for the current Output

Raises:



408
409
410
411
412
413
# File 'lib/punchblock/component/output.rb', line 408

def volume_down!
  raise InvalidActionError, "Cannot volume down an Output that is already voluming." unless not_voluming?
  volume_down_action.tap do |action|
    write_action action
  end
end

#volume_down_actionCommand::Output::VolumeDown

Creates an Rayo volume down message for the current Output

Examples:

output_obj.volume_down_action.to_xml

returns:
  <volume-down xmlns="urn:xmpp:rayo:output:1"/>

Returns:

  • (Command::Output::VolumeDown)

    a Rayo volume down message



399
400
401
402
403
# File 'lib/punchblock/component/output.rb', line 399

def volume_down_action
  VolumeDown.new(:component_id => component_id, :target_call_id => target_call_id).tap do |s|
    s.original_component = self
  end
end

#volume_up!Object

Sends a Rayo volume up message for the current Output

Raises:



382
383
384
385
386
387
# File 'lib/punchblock/component/output.rb', line 382

def volume_up!
  raise InvalidActionError, "Cannot volume up an Output that is already voluming." unless not_voluming?
  volume_up_action.tap do |action|
    write_action action
  end
end

#volume_up_actionCommand::Output::VolumeUp

Creates an Rayo volume up message for the current Output

Examples:

output_obj.volume_up_action.to_xml

returns:
  <volume-up xmlns="urn:xmpp:rayo:output:1"/>

Returns:

  • (Command::Output::VolumeUp)

    a Rayo volume up message



373
374
375
376
377
# File 'lib/punchblock/component/output.rb', line 373

def volume_up_action
  VolumeUp.new(:component_id => component_id, :target_call_id => target_call_id).tap do |s|
    s.original_component = self
  end
end