Class: Plivo::XML::Break
Constant Summary collapse
- VALID_STRENGTH_VALUES =
%w(none x-weak weak medium strong x-strong)
Constants inherited from Element
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Break
constructor
A new instance of Break.
Methods inherited from Element
#add, #add_attribute, #convert_value, #hyphenate, #method_missing, #to_s, #to_xml
Constructor Details
#initialize(attributes = {}) ⇒ Break
Returns a new instance of Break.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/plivo/xml/break.rb', line 8 def initialize(attributes = {}) if attributes && attributes[:strength] && !VALID_STRENGTH_VALUES.include?(attributes[:strength]) raise PlivoXMLError, "invalid attribute value #{attributes[:strength]} for strength" end if attributes && attributes[:time] if attributes[:time].downcase().include?('ms') time = attributes[:time].split('ms')[0].to_i if time<= 0 || time >10000 raise PlivoXMLError, "invalid attribute value #{attributes[:time]} for time attribute. Value for time in milliseconds should be > 0 or < 10000" end elsif attributes[:time].downcase().include?('s') time = attributes[:time].split('s')[0].to_i if time<= 0 || time >10 raise PlivoXMLError, "invalid attribute value #{attributes[:time]} for time attribute. Value for time in seconds should be > 0 or < 10" end else raise PlivoXMLError, "invalid attribute value #{attributes[:time]} for time attribute" end end super(nil, attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plivo::XML::Element