Class: Plivo::XML::SayAs
Constant Summary collapse
- VALID_INTERPRET_AS_ATTRIBUTE_VALUES =
%w(characters spell-out cardinal number ordinal digits fraction unit date time address expletive telephone)
- VALID_FORMAT_ATTRIBUTE_VALUES =
%w(mdy dmy ymd md dm ym my d m y yyyymmdd)
Constants inherited from Element
Instance Attribute Summary
Attributes inherited from Element
Instance Method Summary collapse
-
#initialize(body, attributes = {}) ⇒ SayAs
constructor
A new instance of SayAs.
Methods inherited from Element
#add, #add_attribute, #convert_value, #hyphenate, #method_missing, #to_s, #to_xml
Constructor Details
#initialize(body, attributes = {}) ⇒ SayAs
Returns a new instance of SayAs.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/plivo/xml/say_as.rb', line 10 def initialize(body, attributes = {}) unless attributes && attributes["interpret-as"] raise PlivoXMLError, 'interpret-as is a required attribute for say-as element' end if !VALID_INTERPRET_AS_ATTRIBUTE_VALUES.include?(attributes["interpret-as"]) raise PlivoXMLError, "invalid attribute value #{attributes["interpret-as"]} for interpret-as" end if attributes["interpret-as"]=='date' && attributes[:format] && !VALID_FORMAT_ATTRIBUTE_VALUES.include?(attributes[:format]) raise PlivoXMLError, "invalid attribute value #{attributes[:format]} for format" end super(body, attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Plivo::XML::Element