Class: Plivo::XML::Stream
Constant Summary collapse
- SUPPORTED_BIDIRECTIONAL =
%w(true false)
- SUPPORTED_AUDIOTRACK =
%w(inbound outbound both)
- SUPPORTED_CALLBACKMETHOD =
%w(GET POST)
Constants inherited from Element
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(body, attributes = {}) ⇒ Stream
constructor
A new instance of Stream.
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.
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