Class: RubySpeech::GRXML::OneOf

Inherits:
Element
  • Object
show all
Includes:
XML::Language
Defined in:
lib/ruby_speech/grxml/one_of.rb

Overview

The one-of element is one of the valid expansion elements for the SGR rule element

www.w3.org/TR/speech-grammar/#S2.4 –> XML Form

The one-of element has no attributes

The one-of element identifies a set of alternative elements. Each alternative expansion is contained in a item element. There must be at least one item element contained within a one-of element.

FIXME: Ensure an ‘item’ element is in the oneof block… this may be at the final draw or when OneOf is called…

Constant Summary collapse

VALID_CHILD_TYPES =
[Nokogiri::XML::Element, Nokogiri::XML::Text, Item].freeze

Instance Attribute Summary

Attributes included from RubySpeech::GenericElement

#parent

Instance Method Summary collapse

Methods included from XML::Language

#language, #language=

Methods inherited from Element

module, namespace, root_element, #to_doc

Methods included from RubySpeech::GenericElement

#+, #==, #base_uri, #base_uri=, #build, #children, #clone, #create_node, #embed, #eql?, #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:



25
26
27
28
# File 'lib/ruby_speech/grxml/one_of.rb', line 25

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

#regexp_contentObject

:nodoc:



30
31
32
# File 'lib/ruby_speech/grxml/one_of.rb', line 30

def regexp_content # :nodoc:
  "(#{children.map(&:regexp_content).join '|'})"
end