Sha256: 83c34a3e2f83ebb92432b9c52159ce1f7ec67e467e767ce7567e07f8cf571ded

Contents?: true

Size: 1.01 KB

Versions: 9

Compression:

Stored size: 1.01 KB

Contents

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

      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

9 entries across 9 versions & 1 rubygems

Version Path
ruby_speech-2.1.2-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.1.2 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.1.1-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.1.1 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.1.0-java lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.1.0 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.0.2 lib/ruby_speech/grxml/one_of.rb
ruby_speech-2.0.1 lib/ruby_speech/grxml/one_of.rb
ruby_speech-0.5.0 lib/ruby_speech/grxml/one_of.rb