Class: Plivo::XML::Phoneme

Inherits:
Element
  • Object
show all
Defined in:
lib/plivo/xml/phoneme.rb

Constant Summary collapse

VALID_ALPHABET_ATTRIBUTE_VALUES =
%w(ipa x-sampa x-amazon-pinyin)

Constants inherited from Element

Element::SSML_TAGS

Instance Attribute Summary

Attributes inherited from Element

#name, #node

Instance Method Summary collapse

Methods inherited from Element

#add, #add_attribute, #convert_value, #hyphenate, #method_missing, #to_s, #to_xml

Constructor Details

#initialize(body, attributes = {}) ⇒ Phoneme

Returns a new instance of Phoneme.



9
10
11
12
13
14
15
16
17
# File 'lib/plivo/xml/phoneme.rb', line 9

def initialize(body, attributes = {})
  unless attributes && attributes[:ph]
    raise PlivoXMLError, 'ph attribute is required for Phoneme'
  end
  if attributes && attributes[:alphabet] && !VALID_ALPHABET_ATTRIBUTE_VALUES.include?(attributes[:alphabet])
    raise PlivoXMLError, "invalid attribute value #{attributes[:alphabet]} for alphabet"
  end
  super(body, attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Plivo::XML::Element