class Plivo::XML::SayAs

Constants

VALID_FORMAT_ATTRIBUTE_VALUES
VALID_INTERPRET_AS_ATTRIBUTE_VALUES

Public Class Methods

new(body, attributes = {}) click to toggle source
Calls superclass method Plivo::XML::Element::new
# 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