Sha256: 59cf0d31497e91bec757af62ad0b0f9cad7e352dae01edd07293700261d11725

Contents?: true

Size: 993 Bytes

Versions: 28

Compression:

Stored size: 993 Bytes

Contents

module Plivo
  module XML
    class Lang < Element
      @nestables = %w(Break Emphasis Lang P Phoneme Prosody S SayAs Sub W)
      @valid_attributes = %w(xmllang)

       VALID_LANG_ATTRIBUTE_VALUES = [
        'arb', 'cmn-CN','da-DK','nl-NL','en-AU',
        'en-GB', 'en-IN','en-US','en-GB-WLS','fr-FR',
        'fr-CA','de-DE','hi-IN','is-IS','it-IT',
        'ja-JP','ko-KR','nb-NO','pl-PL','pt-BR',
        'pt-PT','ro-RO','ru-RU','es-ES','es-MX',
        'es-US','sv-SE','tr-TR','cy-GB']


      def initialize(body, attributes = {})
        if attributes && attributes[:xmllang]
          unless VALID_LANG_ATTRIBUTE_VALUES.include?(attributes[:xmllang])
            raise PlivoXMLError, "invalid attribute value #{attributes[:xmllang]} for xmllang"
          end
          super(body, {})
          add_attribute("xml:lang", attributes[:xmllang])
        else
          raise PlivoXMLError, 'xmllang attribute is a required attribute for lang'
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
plivo-4.19.0 lib/plivo/xml/lang.rb
plivo-4.18.0 lib/plivo/xml/lang.rb
plivo-4.17.1 lib/plivo/xml/lang.rb
plivo-4.17.0 lib/plivo/xml/lang.rb
plivo-4.16.0 lib/plivo/xml/lang.rb
plivo-4.15.2 lib/plivo/xml/lang.rb
plivo-4.15.1 lib/plivo/xml/lang.rb
plivo-4.15.0 lib/plivo/xml/lang.rb
plivo-4.14.0 lib/plivo/xml/lang.rb
plivo-4.13.0 lib/plivo/xml/lang.rb
plivo-4.12.0 lib/plivo/xml/lang.rb
plivo-4.11.0 lib/plivo/xml/lang.rb
plivo-4.10.0 lib/plivo/xml/lang.rb
plivo-4.9.1 lib/plivo/xml/lang.rb
plivo-4.9.0 lib/plivo/xml/lang.rb
plivo-4.8.1 lib/plivo/xml/lang.rb
plivo-4.8.0 lib/plivo/xml/lang.rb
plivo-4.7.1 lib/plivo/xml/lang.rb
plivo-4.7.0 lib/plivo/xml/lang.rb
plivo-4.6.1 lib/plivo/xml/lang.rb