Class | REXML::Validation::Choice |
In: |
lib/rexml/validation/relaxng.rb
|
Parent: | State |
# File lib/rexml/validation/relaxng.rb, line 363 363: def initialize context 364: super 365: @choices = [] 366: end
# File lib/rexml/validation/relaxng.rb, line 374 374: def <<( event ) 375: add_event_to_arry( @choices, event ) 376: end
# File lib/rexml/validation/relaxng.rb, line 411 411: def expected 412: #puts "IN CHOICE EXPECTED" 413: #puts "EVENTS = #{@events.inspect}" 414: return [@events[@current]] if @events.size > 0 415: return @choices.collect do |x| 416: if x[0].kind_of? State 417: x[0].expected 418: else 419: x[0] 420: end 421: end.flatten 422: end
# File lib/rexml/validation/relaxng.rb, line 424 424: def inspect 425: "< #{to_s} #{@choices.collect{|e| e.collect{|f|f.to_s}.join(', ')}.join(' or ')} >" 426: end
# File lib/rexml/validation/relaxng.rb, line 406 406: def matches?( event ) 407: return @events[@current].matches?( event ) if @events.size > 0 408: !@choices.find{|evt| evt[0].matches?(event)}.nil? 409: end
# File lib/rexml/validation/relaxng.rb, line 378 378: def next( event ) 379: # Make the choice if we haven't 380: if @events.size == 0 381: c = 0 ; max = @choices.size 382: while c < max 383: if @choices[c][0].class == Ref 384: expand_ref_in( @choices[c], 0 ) 385: @choices += @choices[c] 386: @choices.delete( @choices[c] ) 387: max -= 1 388: else 389: c += 1 390: end 391: end 392: @events = @choices.find { |evt| evt[0].matches? event } 393: # Remove the references 394: # Find the events 395: end 396: #puts "In next with #{event.inspect}." 397: #puts "events is #{@events.inspect}" 398: unless @events 399: @events = [] 400: return nil 401: end 402: #puts "current = #@current" 403: super 404: end
# File lib/rexml/validation/relaxng.rb, line 368 368: def reset 369: super 370: @events = [] 371: @choices.each { |c| c.each { |s| s.reset if s.kind_of? State } } 372: end
# File lib/rexml/validation/relaxng.rb, line 429 429: def add_event_to_arry( arry, evt ) 430: if evt.kind_of? State or evt.class == Ref 431: arry << [evt] 432: elsif evt[0] == :text 433: if arry[-1] and 434: arry[-1][-1].kind_of?( Event ) and 435: arry[-1][-1].event_type == :text and @value 436: 437: arry[-1][-1].event_arg = evt[1] 438: @value = false 439: end 440: else 441: arry << [] if evt[0] == :start_element 442: arry[-1] << generate_event( evt ) 443: end 444: end