Class: REXML::Validation::Interleave (Ruby 2.4.2)
Description: Class : REXML::Validation::Interleave - Ruby 2.4.2

Support for the Ruby 2.4 series has ended. See here for reference.

### Home Classes Methods

### In Files

- rexml/validation/relaxng.rb

### Parent

REXML::Validation::Choice

### Methods

- ::new
- #expected
- #inspect
- #matches?
- #next
- #next_current
- #reset

### Class/Module Index

Quicksearch

- Array
- Float
- Integer
- Object
- REXML
- REXML::AttlistDecl
- REXML::Attribute
- REXML::Attributes
- REXML::CData
- REXML::Child
- REXML::Comment
- REXML::DTD
- REXML::DTD::AttlistDecl
- REXML::DTD::ElementDecl
- REXML::DTD::EntityDecl
- REXML::DTD::NotationDecl
- REXML::DTD::Parser
- REXML::Declaration
- REXML::DocType
- REXML::Document
- REXML::Element
- REXML::ElementDecl
- REXML::Elements
- REXML::Encoding
- REXML::Entity
- REXML::EntityConst
- REXML::ExternalEntity
- REXML::Formatters
- REXML::Formatters::Default
- REXML::Formatters::Pretty
- REXML::Formatters::Transitive
- REXML::Functions
- REXML::IOSource
- REXML::Instruction
- REXML::Light
- REXML::Light::Node
- REXML::Namespace
- REXML::Node
- REXML::NotationDecl
- REXML::Output
- REXML::Parent
- REXML::ParseException
- REXML::Parsers
- REXML::Parsers::BaseParser
- REXML::Parsers::LightParser
- REXML::Parsers::PullEvent
- REXML::Parsers::PullParser
- REXML::Parsers::SAX2Parser
- REXML::Parsers::StreamParser
- REXML::Parsers::TreeParser
- REXML::Parsers::UltraLightParser
- REXML::Parsers::XPathParser
- REXML::QuickPath
- REXML::SAX2Listener
- REXML::Security
- REXML::Source
- REXML::SourceFactory
- REXML::StreamListener
- REXML::SyncEnumerator
- REXML::Text
- REXML::UndefinedNamespaceException
- REXML::Validation
- REXML::Validation::Choice
- REXML::Validation::Event
- REXML::Validation::Interleave
- REXML::Validation::OneOrMore
- REXML::Validation::Optional
- REXML::Validation::Ref
- REXML::Validation::RelaxNG
- REXML::Validation::Sequence
- REXML::Validation::State
- REXML::Validation::ValidationException
- REXML::Validation::Validator
- REXML::Validation::ZeroOrMore
- REXML::XMLDecl
- REXML::XMLTokens
- REXML::XPath
- REXML::XPathParser
- Symbol

No matching classes.

# REXML::Validation::Interleave

### Public Class Methods

new(context) click to toggle source

                   # File rexml/validation/relaxng.rb, line 440
    def initialize context
      super
      @choice = 0
    end

### Public Instance Methods

expected() click to toggle source

                   # File rexml/validation/relaxng.rb, line 511
    def expected
      return [@events[@current]] if @events[@current]
      return @choices[@choice..-1].collect do |x|
        if x[0].kind_of? State
          x[0].expected
        else
          x[0]
        end
      end.flatten
    end

inspect() click to toggle source

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

matches?( event ) click to toggle source

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

next( event ) click to toggle source

                   # File rexml/validation/relaxng.rb, line 477
    def next( event )
      # Find the next series
      next_current(event) unless @events[@current]
      return nil unless @events[@current]

      expand_ref_in( @events, @current ) if @events[@current].class == Ref
      if ( @events[@current].kind_of? State )
        @current += 1
        @events[@current-1].previous = self
        return @events[@current-1].next( event )
      end
      return @previous.pop.next( event ) if @events[@current].nil?
      if ( @events[@current].matches?(event) )
        @current += 1
        if @events[@current].nil?
          return self unless @choices[@choice].nil?
          return @previous.pop
        elsif @events[@current].kind_of? State
          @current += 1
          @events[@current-1].previous = self
          return @events[@current-1]
        else
          return self
        end
      else
        return nil
      end
    end

next_current( event ) click to toggle source

                   # File rexml/validation/relaxng.rb, line 449
    def next_current( event )
      # Expand references
      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[@choice..-1].find { |evt| evt[0].matches? event }
      @current = 0
      if @events
        # reorder the choices
        old = @choices[@choice]
        idx = @choices.index( @events )
        @choices[@choice] = @events
        @choices[idx] = old
        @choice += 1
      end

      @events = [] unless @events
    end

reset() click to toggle source

                   # File rexml/validation/relaxng.rb, line 445
    def reset
      @choice = 0
    end