Class: Voice::Actions::Stream
- Inherits:
-
Object
- Object
- Voice::Actions::Stream
- Defined in:
- lib/vonage/voice/actions/stream.rb
Instance Attribute Summary collapse
-
#bargeIn ⇒ Object
Returns the value of attribute bargeIn.
-
#level ⇒ Object
Returns the value of attribute level.
-
#loop ⇒ Object
Returns the value of attribute loop.
-
#streamUrl ⇒ Object
Returns the value of attribute streamUrl.
Instance Method Summary collapse
- #action ⇒ Object
- #after_initialize! ⇒ Object
- #create_stream!(builder) ⇒ Object
-
#initialize(attributes = {}) ⇒ Stream
constructor
A new instance of Stream.
- #verify_barge_in ⇒ Object
- #verify_level ⇒ Object
- #verify_loop ⇒ Object
- #verify_stream_url ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Stream
Returns a new instance of Stream.
8 9 10 11 12 13 14 15 |
# File 'lib/vonage/voice/actions/stream.rb', line 8 def initialize(attributes = {}) @streamUrl = attributes.fetch(:streamUrl) @level = attributes.fetch(:level, nil) @bargeIn = attributes.fetch(:bargeIn, nil) @loop = attributes.fetch(:loop, nil) after_initialize! end |
Instance Attribute Details
#bargeIn ⇒ Object
Returns the value of attribute bargeIn.
6 7 8 |
# File 'lib/vonage/voice/actions/stream.rb', line 6 def @bargeIn end |
#level ⇒ Object
Returns the value of attribute level.
6 7 8 |
# File 'lib/vonage/voice/actions/stream.rb', line 6 def level @level end |
#loop ⇒ Object
Returns the value of attribute loop.
6 7 8 |
# File 'lib/vonage/voice/actions/stream.rb', line 6 def loop @loop end |
#streamUrl ⇒ Object
Returns the value of attribute streamUrl.
6 7 8 |
# File 'lib/vonage/voice/actions/stream.rb', line 6 def streamUrl @streamUrl end |
Instance Method Details
#action ⇒ Object
53 54 55 |
# File 'lib/vonage/voice/actions/stream.rb', line 53 def action create_stream!(self) end |
#after_initialize! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/vonage/voice/actions/stream.rb', line 17 def after_initialize! verify_stream_url if self.level verify_level end if self. end if self.loop verify_loop end end |
#create_stream!(builder) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vonage/voice/actions/stream.rb', line 57 def create_stream!(builder) ncco = [ { action: 'stream', streamUrl: builder.streamUrl } ] ncco[0].merge!(level: builder.level) if builder.level ncco[0].merge!(bargeIn: builder.) if (builder. || builder. == false) ncco[0].merge!(loop: builder.loop) if builder.loop ncco end |
#verify_barge_in ⇒ Object
45 46 47 |
# File 'lib/vonage/voice/actions/stream.rb', line 45 def raise ClientError.new("Expected 'bargeIn' value to be a Boolean") unless self. == true || self. == false end |
#verify_level ⇒ Object
41 42 43 |
# File 'lib/vonage/voice/actions/stream.rb', line 41 def verify_level raise ClientError.new("Expected 'level' value to be a number between -1 and 1") unless self.level.between?(-1, 1) end |
#verify_loop ⇒ Object
49 50 51 |
# File 'lib/vonage/voice/actions/stream.rb', line 49 def verify_loop raise ClientError.new("Expected 'loop' value to be either 1 or 0") unless self.loop == 1 || self.loop == 0 end |
#verify_stream_url ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/vonage/voice/actions/stream.rb', line 33 def verify_stream_url raise ClientError.new("Expected 'streamUrl' parameter to be an Array containing a single string item") unless self.streamUrl.is_a?(Array) uri = URI.parse(self.streamUrl[0]) raise ClientError.new("Invalid 'streamUrl' value, must be a valid URL") unless uri.kind_of?(URI::HTTP) || uri.kind_of?(URI::HTTPS) end |