Class: Plivo::XML::Stream

Inherits:
Element
  • Object
show all
Defined in:
lib/plivo/xml/stream.rb

Constant Summary collapse

SUPPORTED_BIDIRECTIONAL =
%w(true false)
SUPPORTED_AUDIOTRACK =
%w(inbound outbound both)
SUPPORTED_CALLBACKMETHOD =
%w(GET POST)

Constants inherited from Element

Element::SSML_TAGS

Instance Attribute Summary

Attributes inherited from Element

#name, #node

Instance Method Summary collapse

Methods inherited from Element

#add, #add_attribute, #convert_value, #hyphenate, #method_missing, #to_s, #to_xml

Constructor Details

#initialize(body, attributes = {}) ⇒ Stream

Returns a new instance of Stream.

Raises:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/plivo/xml/stream.rb', line 12

def initialize(body, attributes = {})
  if attributes[:bidirectional] && !SUPPORTED_BIDIRECTIONAL.include?(attributes[:bidirectional])
    raise PlivoXMLError, "<Stream> bidirectional #{attributes[:bidirectional]} is not valid."
  end
  if attributes[:audioTrack] && !SUPPORTED_AUDIOTRACK.include?(attributes[:audioTrack])
    raise PlivoXMLError, "<Stream> audioTrack #{attributes[:audioTrack]} is not valid."
  end
  if attributes[:statusCallbackMethod] && !SUPPORTED_CALLBACKMETHOD.include?(attributes[:statusCallbackMethod].upcase)
    raise PlivoXMLError, "<Stream> statusCallbackMethod #{attributes[:statusCallbackMethod]} is not valid."
  end
  raise PlivoXMLError, 'No text set for Stream' unless body
  super(body, attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plivo::XML::Element