Class: Plivo::XML::Prosody
Constant Summary collapse
- VALID_VOLUME_ATTRIBUTE_VALUES =
%w(default silent x-soft soft medium loud x-loud)
- VALID_RATE_ATTRIBUTE_VALUES =
%w(x-slow slow medium fast x-fast)
- VALID_PITCH_ATTRIBUTE_VALUES =
%w(default x-low low medium high x-high)
Constants inherited from Element
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(body, attributes = {}) ⇒ Prosody
constructor
A new instance of Prosody.
Methods inherited from Element
#add, #add_attribute, #convert_value, #hyphenate, #method_missing, #to_s, #to_xml
Constructor Details
#initialize(body, attributes = {}) ⇒ Prosody
Returns a new instance of Prosody.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/plivo/xml/prosody.rb', line 11 def initialize(body, attributes = {}) if attributes.nil? || attributes.length == 0 raise PlivoXMLError, 'Specify at least one attribute for Prosody tag' end if attributes[:volume] && !VALID_VOLUME_ATTRIBUTE_VALUES.include?(attributes[:volume]) && !attributes[:volume].include?('dB') raise PlivoXMLError, "invalid attribute value #{attributes[:volume]} for volume" end if attributes[:rate] && !VALID_RATE_ATTRIBUTE_VALUES.include?(attributes[:rate]) && (!attributes[:rate].include?('%') || attributes[:rate].split('%')[0].to_i < 0) raise PlivoXMLError, "invalid attribute value #{attributes[:rate]} for rate" end if attributes[:pitch] && !VALID_PITCH_ATTRIBUTE_VALUES.include?(attributes[:pitch]) && !attributes[:pitch].include?('%') raise PlivoXMLError, "invalid attribute value #{attributes[:pitch]} for pitch" end super(body, attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plivo::XML::Element