123456789_123456789_123456789_123456789_123456789_

Class: REXML::Validation::OneOrMore

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, State
Instance Chain:
self, State
Inherits: REXML::Validation::State
Defined in: lib/rexml/validation/relaxng.rb

Class Method Summary

State - Inherited

Instance Attribute Summary

State - Inherited

Instance Method Summary

Constructor Details

.new(context) ⇒ OneOrMore

[ GitHub ]

  
# File 'lib/rexml/validation/relaxng.rb', line 312

def initialize context
  super
  @ord = 0
end

Instance Method Details

#expected

[ GitHub ]

  
# File 'lib/rexml/validation/relaxng.rb', line 348

def expected
  if @current == 0 and @ord > 0
    return [@previous[-1].expected, @events[0]].flatten
  else
    return [@events[@current]]
  end
end

#matches?(event) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rexml/validation/relaxng.rb', line 343

def matches?( event )
  @events[@current].matches?(event) ||
  (@current == 0 and @ord > 0 and @previous[-1].matches?(event))
end

#next(event)

[ GitHub ]

  
# File 'lib/rexml/validation/relaxng.rb', line 322

def next( event )
  expand_ref_in( @events, @current ) if @events[@current].class == Ref
  if ( @events[@current].matches?(event) )
    @current += 1
    @ord += 1
    if @events[@current].nil?
      @current = 0
      return self
    elsif @events[@current].kind_of? State
      @current += 1
      @events[@current-1].previous = self
      return @events[@current-1]
    else
      return self
    end
  else
    return @previous.pop.next( event ) if @current == 0 and @ord > 0
    return nil
  end
end

#reset

[ GitHub ]

  
# File 'lib/rexml/validation/relaxng.rb', line 317

def reset
  super
  @ord = 0
end