Class: Punchblock::Component::Output

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

Defined Under Namespace

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

Instance Attribute Summary

Attributes inherited from ComponentNode

#complete_event

Attributes inherited from RayoNode

#call_id, #client, #component_id, #connection, #original_component

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MediaContainer

#inspect_attributes, #ssml, #ssml=, #voice, #voice=

Methods inherited from ComponentNode

#add_event, #initialize, #register_event_handler, #register_initial_handlers, #response=, #stop!, #stop_action, #write_action

Methods inherited from Punchblock::CommandNode

#initialize, #response, #response=, #write_attr

Methods inherited from RayoNode

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

Constructor Details

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

Class Method Details

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

Creates an Rayo Output command

Examples:

output :text => 'Hello brown cow.'

returns:
  <output xmlns="urn:xmpp:tropo:output:1">Hello brown cow.</output>

Parameters:

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

Options Hash (options):

  • :text (String, Optional)

    to speak back

  • :voice (String, Optional)

    with which to render TTS

  • :ssml (String, Optional)

    document to render TTS

Returns:

  • (Command::Output)

    an Rayo “output” command



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/punchblock/component/output.rb', line 24

def self.new(options = {})
  super().tap do |new_node|
    case options
    when Hash
      new_node.voice = options.delete(:voice) if options[:voice]
      new_node.ssml = options.delete(:ssml) if options[:ssml]
      new_node << options.delete(:text) if options[:text]
      options.each_pair { |k,v| new_node.send :"#{k}=", v }
    when Nokogiri::XML::Element
      new_node.inherit options
    end
  end
end

Instance Method Details

#interrupt_onString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



41
42
43
# File 'lib/punchblock/component/output.rb', line 41

def interrupt_on
  read_attr :'interrupt-on', :to_sym
end

#interrupt_on=(other) ⇒ Object

Parameters:

  • voice (String)

    to use when rendering TTS



48
49
50
# File 'lib/punchblock/component/output.rb', line 48

def interrupt_on=(other)
  write_attr :'interrupt-on', other
end

#max_timeString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



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

def max_time
  read_attr(:'max-time').to_i
end

#max_time=(other) ⇒ Object

Parameters:

  • voice (String)

    to use when rendering TTS



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

def max_time=(other)
  write_attr :'max-time', other
end

#pause!Object

Sends an Rayo pause message for the current Output

Raises:



148
149
150
151
152
153
154
# File 'lib/punchblock/component/output.rb', line 148

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:tropo:output:1"/>

Returns:

  • (Command::Output::Pause)

    an Rayo pause message for the current Output



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

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

#repeat_intervalString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



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

def repeat_interval
  read_attr :'repeat-interval', :to_i
end

#repeat_interval=(other) ⇒ Object

Parameters:

  • voice (String)

    to use when rendering TTS



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

def repeat_interval=(other)
  write_attr :'repeat-interval', other
end

#repeat_timesString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



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

def repeat_times
  read_attr :'repeat-times', :to_i
end

#repeat_times=(other) ⇒ Object

Parameters:

  • voice (String)

    to use when rendering TTS



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

def repeat_times=(other)
  write_attr :'repeat-times', other
end

#resume!Object

Sends an Rayo resume message for the current Output

Raises:



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

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:tropo:output:1"/>

Returns:

  • (Command::Output::Resume)

    an Rayo resume message



166
167
168
# File 'lib/punchblock/component/output.rb', line 166

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

#seek!(options = {}) ⇒ Object

Sends a Rayo seek message for the current Output

Raises:



208
209
210
211
212
213
# File 'lib/punchblock/component/output.rb', line 208

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



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

def seek_action(options = {})
  Seek.new({ :component_id => component_id, :call_id => 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:



299
300
301
302
303
304
# File 'lib/punchblock/component/output.rb', line 299

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



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

def slow_down_action
  SlowDown.new(:component_id => component_id, :call_id => 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:



273
274
275
276
277
278
# File 'lib/punchblock/component/output.rb', line 273

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



264
265
266
267
268
# File 'lib/punchblock/component/output.rb', line 264

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

#start_offsetString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



55
56
57
# File 'lib/punchblock/component/output.rb', line 55

def start_offset
  read_attr :'start-offset', :to_i
end

#start_offset=(other) ⇒ Object

Parameters:

  • voice (String)

    to use when rendering TTS



62
63
64
# File 'lib/punchblock/component/output.rb', line 62

def start_offset=(other)
  write_attr :'start-offset', other
end

#start_pausedString

Returns the TTS voice to use.

Returns:

  • (String)

    the TTS voice to use



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

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

#start_paused=(other) ⇒ Object

Parameters:

  • voice (String)

    to use when rendering TTS



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

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

#volume_down!Object

Sends a Rayo volume down message for the current Output

Raises:



393
394
395
396
397
398
# File 'lib/punchblock/component/output.rb', line 393

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



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

def volume_down_action
  VolumeDown.new(:component_id => component_id, :call_id => 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:



367
368
369
370
371
372
# File 'lib/punchblock/component/output.rb', line 367

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



358
359
360
361
362
# File 'lib/punchblock/component/output.rb', line 358

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