Class: RubySpeech::SSML::Sub

Inherits:
Element
  • Object
show all
Defined in:
lib/ruby_speech/ssml/sub.rb

Overview

The sub element is employed to indicate that the text in the alias attribute value replaces the contained text for pronunciation. This allows a document to contain both a spoken and written form. The required alias attribute specifies the string to be spoken instead of the enclosed string. The processor should apply text normalization to the alias value.

The sub element can only contain text (no elements).

www.w3.org/TR/speech-synthesis/#S3.1.10

Constant Summary collapse

VALID_CHILD_TYPES =
[Nokogiri::XML::Text, String].freeze

Instance Attribute Summary

Attributes included from GenericElement

#parent

Instance Method Summary collapse

Methods inherited from Element

module, namespace, root_element, #to_doc

Methods included from GenericElement

#+, #==, #base_uri, #base_uri=, #build, #children, #clone, #create_node, #embed, #eval_dsl_block, included, #inherit, #initialize, #inspect, #mass_assign, #method_missing, #namespace=, #namespace_href, #node, #nokogiri_children, #read_attr, #respond_to_missing?, #string, #to_s, #traverse, #version, #version=, #write_attr

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RubySpeech::GenericElement

Instance Method Details

#<<(arg) ⇒ Object

Raises:



34
35
36
37
# File 'lib/ruby_speech/ssml/sub.rb', line 34

def <<(arg)
  raise InvalidChildError, "A Sub can only accept Strings as children" unless VALID_CHILD_TYPES.include? arg.class
  super
end

#aliasString

Indicates the string to be spoken instead of the enclosed string

Returns:

  • (String)


23
24
25
# File 'lib/ruby_speech/ssml/sub.rb', line 23

def alias
  read_attr :alias
end

#alias=(other) ⇒ Object

Parameters:

  • other (String)

    the string to be spoken instead of the enclosed string



30
31
32
# File 'lib/ruby_speech/ssml/sub.rb', line 30

def alias=(other)
  self[:alias] = other
end

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/ruby_speech/ssml/sub.rb', line 39

def eql?(o)
  super o, :alias
end