Class: REXML::Validation::Choice

Class | REXML::Validation::Choice
In: | rexml/validation/relaxng.rb
Parent: | State

### Methods

<< expected inspect matches? new next reset

### Public Class methods

new(context)

[Source]

    # File rexml/validation/relaxng.rb, line 363
          def initialize context
            super
            @choices = []
          end

### Public Instance methods

<<( event )

[Source]

    # File rexml/validation/relaxng.rb, line 374
          def <<( event )
            add_event_to_arry( @choices, event )
          end

expected()

[Source]

    # File rexml/validation/relaxng.rb, line 411
          def expected
            #puts "IN CHOICE EXPECTED"
            #puts "EVENTS = #{@events.inspect}"
            return [@events[@current]] if @events.size > 0
            return @choices.collect do |x|
              if x[0].kind_of? State
                x[0].expected
              else
                x[0]
              end
            end.flatten
          end

inspect()

[Source]

    # File rexml/validation/relaxng.rb, line 424
          def inspect
            "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' or ')} >"
          end

matches?( event )

[Source]

    # File rexml/validation/relaxng.rb, line 406
          def matches?( event )
            return @events[@current].matches?( event ) if @events.size > 0
            !@choices.find{|evt| evt[0].matches?(event)}.nil?
          end

next( event )

[Source]

    # File rexml/validation/relaxng.rb, line 378
          def next( event )
            # Make the choice if we haven't
            if @events.size == 0
              c = 0 ; max = @choices.size
              while c < max
                if @choices[c][0].class == Ref
                  expand_ref_in( @choices[c], 0 )
                  @choices += @choices[c]
                  @choices.delete( @choices[c] )
                  max -= 1
                else
                  c += 1
                end
              end
              @events = @choices.find { |evt| evt[0].matches? event }
              # Remove the references
              # Find the events
            end
            #puts "In next with #{event.inspect}."
            #puts "events is #{@events.inspect}"
            unless @events
              @events = []
              return nil
            end
            #puts "current = #@current"
            super
          end

reset()

[Source]

    # File rexml/validation/relaxng.rb, line 368
          def reset
            super
            @events = []
            @choices.each { |c| c.each { |s| s.reset if s.kind_of? State } }
          end

[Validate]