Class: Punchblock::Component::Output
- Inherits:
-
ComponentNode
- Object
- Niceogiri::XML::Node
- RayoNode
- Punchblock::CommandNode
- ComponentNode
- Punchblock::Component::Output
- Defined in:
- lib/punchblock/component/output.rb
Defined Under Namespace
Classes: Complete, Pause, Resume, Seek, SlowDown, SpeedUp, VolumeDown, VolumeUp
Constant Summary
Constants inherited from RayoNode
Instance Attribute Summary
Attributes inherited from RayoNode
#client, #component_id, #connection, #domain, #original_component, #target_call_id, #target_mixer_name
Class Method Summary collapse
-
.new(options = {}) ⇒ Command::Output
Creates an Rayo Output command.
Instance Method Summary collapse
- #inspect_attributes ⇒ Object
-
#interrupt_on ⇒ Symbol
Input type on which to interrupt output.
- #interrupt_on=(other) ⇒ Object
-
#max_time ⇒ Integer
Indicates the maximum amount of time for which the output should be allowed to run before being terminated.
- #max_time=(other) ⇒ Object
-
#pause! ⇒ Object
Sends an Rayo pause message for the current Output.
-
#pause_action ⇒ Command::Output::Pause
Pauses a running Output.
-
#renderer ⇒ String
The rendering engine requested by the component.
- #renderer=(renderer) ⇒ Object
-
#repeat_interval ⇒ Integer
Indicates the duration of silence that should space repeats of the rendered document.
- #repeat_interval=(other) ⇒ Object
-
#repeat_times ⇒ Integer
Indicates the number of times the output should be played.
- #repeat_times=(other) ⇒ Object
-
#resume! ⇒ Object
Sends an Rayo resume message for the current Output.
-
#resume_action ⇒ Command::Output::Resume
Create an Rayo resume message for the current Output.
-
#seek!(options = {}) ⇒ Object
Sends a Rayo seek message for the current Output.
-
#seek_action(options = {}) ⇒ Command::Output::Seek
Creates an Rayo seek message for the current Output.
-
#slow_down! ⇒ Object
Sends a Rayo slow down message for the current Output.
-
#slow_down_action ⇒ Command::Output::SlowDown
Creates an Rayo slow down message for the current Output.
-
#speed_up! ⇒ Object
Sends a Rayo speed up message for the current Output.
-
#speed_up_action ⇒ Command::Output::SpeedUp
Creates an Rayo speed up message for the current Output.
-
#ssml ⇒ String
The SSML document to render TTS.
- #ssml=(ssml) ⇒ Object
-
#start_offset ⇒ Integer
Indicates some offset through which the output should be skipped before rendering begins.
- #start_offset=(other) ⇒ Object
-
#start_paused ⇒ true, false
Indicates wether or not the component should be started in a paused state to be resumed at a later time.
- #start_paused=(other) ⇒ Object
-
#voice ⇒ String
The TTS voice to use.
- #voice=(voice) ⇒ Object
-
#volume_down! ⇒ Object
Sends a Rayo volume down message for the current Output.
-
#volume_down_action ⇒ Command::Output::VolumeDown
Creates an Rayo volume down message for the current Output.
-
#volume_up! ⇒ Object
Sends a Rayo volume up message for the current Output.
-
#volume_up_action ⇒ Command::Output::VolumeUp
Creates an Rayo volume up message for the current Output.
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::Output
Creates an Rayo Output command
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/punchblock/component/output.rb', line 30 def self.new( = {}) super().tap do |new_node| case when Hash new_node.ssml = .delete(:ssml) if [:ssml] new_node << .delete(:text) if [:text] .each_pair { |k,v| new_node.send :"#{k}=", v } when Nokogiri::XML::Element new_node.inherit end end end |
Instance Method Details
#inspect_attributes ⇒ Object
174 175 176 |
# File 'lib/punchblock/component/output.rb', line 174 def inspect_attributes super + [:voice, :ssml, :interrupt_on, :start_offset, :start_paused, :repeat_interval, :repeat_times, :max_time, :renderer] end |
#interrupt_on ⇒ Symbol
Returns input type on which to interrupt output.
79 80 81 |
# File 'lib/punchblock/component/output.rb', line 79 def interrupt_on read_attr :'interrupt-on', :to_sym end |
#interrupt_on=(other) ⇒ Object
86 87 88 |
# File 'lib/punchblock/component/output.rb', line 86 def interrupt_on=(other) write_attr :'interrupt-on', other end |
#max_time ⇒ Integer
Returns Indicates the maximum amount of time for which the output should be allowed to run before being terminated. Includes repeats.
149 150 151 |
# File 'lib/punchblock/component/output.rb', line 149 def max_time read_attr :'max-time', :to_i end |
#max_time=(other) ⇒ Object
156 157 158 |
# File 'lib/punchblock/component/output.rb', line 156 def max_time=(other) write_attr :'max-time', other, :to_i end |
#pause! ⇒ Object
Sends an Rayo pause message for the current Output
204 205 206 207 208 209 210 |
# File 'lib/punchblock/component/output.rb', line 204 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_action ⇒ Command::Output::Pause
Pauses a running Output
197 198 199 |
# File 'lib/punchblock/component/output.rb', line 197 def pause_action Pause.new :component_id => component_id, :target_call_id => target_call_id end |
#renderer ⇒ String
Returns the rendering engine requested by the component.
163 164 165 |
# File 'lib/punchblock/component/output.rb', line 163 def renderer read_attr :renderer end |
#renderer=(renderer) ⇒ Object
170 171 172 |
# File 'lib/punchblock/component/output.rb', line 170 def renderer=(renderer) write_attr :renderer, renderer end |
#repeat_interval ⇒ Integer
Returns Indicates the duration of silence that should space repeats of the rendered document.
121 122 123 |
# File 'lib/punchblock/component/output.rb', line 121 def repeat_interval read_attr :'repeat-interval', :to_i end |
#repeat_interval=(other) ⇒ Object
128 129 130 |
# File 'lib/punchblock/component/output.rb', line 128 def repeat_interval=(other) write_attr :'repeat-interval', other, :to_i end |
#repeat_times ⇒ Integer
Returns Indicates the number of times the output should be played.
135 136 137 |
# File 'lib/punchblock/component/output.rb', line 135 def repeat_times read_attr :'repeat-times', :to_i end |
#repeat_times=(other) ⇒ Object
142 143 144 |
# File 'lib/punchblock/component/output.rb', line 142 def repeat_times=(other) write_attr :'repeat-times', other, :to_i end |
#resume! ⇒ Object
Sends an Rayo resume message for the current Output
229 230 231 232 233 234 235 |
# File 'lib/punchblock/component/output.rb', line 229 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_action ⇒ Command::Output::Resume
Create an Rayo resume message for the current Output
222 223 224 |
# File 'lib/punchblock/component/output.rb', line 222 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
264 265 266 267 268 269 |
# File 'lib/punchblock/component/output.rb', line 264 def seek!( = {}) raise InvalidActionError, "Cannot seek an Output that is already seeking." if seeking? seek_action().tap do |action| write_action action end end |
#seek_action(options = {}) ⇒ Command::Output::Seek
Creates an Rayo seek message for the current Output
255 256 257 258 259 |
# File 'lib/punchblock/component/output.rb', line 255 def seek_action( = {}) Seek.new({ :component_id => component_id, :target_call_id => target_call_id }.merge()).tap do |s| s.original_component = self end end |
#slow_down! ⇒ Object
Sends a Rayo slow down message for the current Output
355 356 357 358 359 360 |
# File 'lib/punchblock/component/output.rb', line 355 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_action ⇒ Command::Output::SlowDown
Creates an Rayo slow down message for the current Output
346 347 348 349 350 |
# File 'lib/punchblock/component/output.rb', line 346 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
329 330 331 332 333 334 |
# File 'lib/punchblock/component/output.rb', line 329 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_action ⇒ Command::Output::SpeedUp
Creates an Rayo speed up message for the current Output
320 321 322 323 324 |
# File 'lib/punchblock/component/output.rb', line 320 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 ⇒ String
Returns the SSML document to render TTS.
60 61 62 63 |
# File 'lib/punchblock/component/output.rb', line 60 def ssml node = children.first RubySpeech::SSML.import node if node end |
#ssml=(ssml) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/punchblock/component/output.rb', line 68 def ssml=(ssml) return unless ssml unless ssml.is_a?(RubySpeech::SSML::Element) ssml = RubySpeech::SSML.import ssml end self << ssml end |
#start_offset ⇒ Integer
Returns Indicates some offset through which the output should be skipped before rendering begins.
93 94 95 |
# File 'lib/punchblock/component/output.rb', line 93 def start_offset read_attr :'start-offset', :to_i end |
#start_offset=(other) ⇒ Object
100 101 102 |
# File 'lib/punchblock/component/output.rb', line 100 def start_offset=(other) write_attr :'start-offset', other, :to_i end |
#start_paused ⇒ true, false
Returns Indicates wether or not the component should be started in a paused state to be resumed at a later time.
107 108 109 |
# File 'lib/punchblock/component/output.rb', line 107 def start_paused read_attr(:'start-paused') == 'true' end |
#start_paused=(other) ⇒ Object
114 115 116 |
# File 'lib/punchblock/component/output.rb', line 114 def start_paused=(other) write_attr :'start-paused', other, :to_s end |
#voice ⇒ String
Returns the TTS voice to use.
46 47 48 |
# File 'lib/punchblock/component/output.rb', line 46 def voice read_attr :voice end |
#voice=(voice) ⇒ Object
53 54 55 |
# File 'lib/punchblock/component/output.rb', line 53 def voice=(voice) write_attr :voice, voice end |
#volume_down! ⇒ Object
Sends a Rayo volume down message for the current Output
449 450 451 452 453 454 |
# File 'lib/punchblock/component/output.rb', line 449 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_action ⇒ Command::Output::VolumeDown
Creates an Rayo volume down message for the current Output
440 441 442 443 444 |
# File 'lib/punchblock/component/output.rb', line 440 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
423 424 425 426 427 428 |
# File 'lib/punchblock/component/output.rb', line 423 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_action ⇒ Command::Output::VolumeUp
Creates an Rayo volume up message for the current Output
414 415 416 417 418 |
# File 'lib/punchblock/component/output.rb', line 414 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 |