Class: Punchblock::Component::Output

Inherits:
ComponentNode show all
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 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

- (Object) inherit(xml_node)



67
68
69
70
71
# File 'lib/punchblock/component/output.rb', line 67

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

- (Symbol) interrupt_on



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

attribute :interrupt_on, Symbol

- (Integer) max_time



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

attribute :max_time, Integer

- (Object) pause!

Sends an Rayo pause message for the current Output

Raises:



160
161
162
163
164
165
166
# File 'lib/punchblock/component/output.rb', line 160

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

- (Command::Output::Pause) pause_action

Pauses a running Output

Examples:

output_obj.pause_action.to_xml

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


153
154
155
# File 'lib/punchblock/component/output.rb', line 153

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

- (Object) rayo_attributes



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/punchblock/component/output.rb', line 97

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

- (Object) rayo_children(root)



110
111
112
113
114
115
# File 'lib/punchblock/component/output.rb', line 110

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

- (Object) render_document=(other)

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



126
127
128
# File 'lib/punchblock/component/output.rb', line 126

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

- (Document) render_documents



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

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

- (String) renderer



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

attribute :renderer, String

- (Integer) repeat_interval



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

attribute :repeat_interval, Integer

- (Integer) repeat_times



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

attribute :repeat_times, Integer

- (Object) resume!

Sends an Rayo resume message for the current Output

Raises:



185
186
187
188
189
190
191
# File 'lib/punchblock/component/output.rb', line 185

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

- (Command::Output::Resume) resume_action

Create an Rayo resume message for the current Output

Examples:

output_obj.resume_action.to_xml

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


178
179
180
# File 'lib/punchblock/component/output.rb', line 178

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

- (Object) seek!(options = {})

Sends a Rayo seek message for the current Output

Raises:



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

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

- (Command::Output::Seek) seek_action(options = {})

Creates an Rayo seek message for the current Output

Examples:

output_obj.seek_action.to_xml

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


211
212
213
214
215
# File 'lib/punchblock/component/output.rb', line 211

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

- (Object) slow_down!

Sends a Rayo slow down message for the current Output

Raises:



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

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

- (Command::Output::SlowDown) slow_down_action

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"/>


294
295
296
297
298
# File 'lib/punchblock/component/output.rb', line 294

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

- (Object) speed_up!

Sends a Rayo speed up message for the current Output

Raises:



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

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

- (Command::Output::SpeedUp) speed_up_action

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"/>


268
269
270
271
272
# File 'lib/punchblock/component/output.rb', line 268

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

- (Object) ssml=(other)



130
131
132
# File 'lib/punchblock/component/output.rb', line 130

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

- (Integer) start_offset



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

attribute :start_offset, Integer

- (true, false) start_paused



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

attribute :start_paused, Boolean

- (String) voice



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

attribute :voice, String

- (Object) volume_down!

Sends a Rayo volume down message for the current Output

Raises:



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

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

- (Command::Output::VolumeDown) volume_down_action

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"/>


388
389
390
391
392
# File 'lib/punchblock/component/output.rb', line 388

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

- (Object) volume_up!

Sends a Rayo volume up message for the current Output

Raises:



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

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

- (Command::Output::VolumeUp) volume_up_action

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"/>


362
363
364
365
366
# File 'lib/punchblock/component/output.rb', line 362

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