Sha256: 11b6c8ed19c634703b27c788eb3aa3d9fa96667976c3a0e7fb6389839926ac25

Contents?: true

Size: 1.11 KB

Versions: 18

Compression:

Stored size: 1.11 KB

Contents

require 'ruby_speech/xml/language'
require 'ruby_speech/grxml/item'

module RubySpeech
  module GRXML
    ##
    #
    # The one-of element is one of the valid expansion elements for the SGR rule element
    #
    # http://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...
    #
    class OneOf < Element
      include XML::Language

      register :'one-of'

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

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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ruby_speech-3.0.1-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-3.0.1 lib/ruby_speech/grxml/one_of.rb
ruby_speech-3.0.0-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-3.0.0 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.4.0-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.4.0 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.3.2-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.3.2 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.3.1-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.3.1 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.3.0-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.3.0 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.2.2-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.2.2 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.2.1-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.2.1 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.2.0-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.2.0 lib/ruby_speech/grxml/one_of.rb