Class: REXML::Validation::Choice
- Defined in:
- lib/extensions/rexml/rexml/validation/relaxng.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<<(event) ⇒ Object
- #expected ⇒ Object
-
#initialize(context) ⇒ Choice
constructor
A new instance of Choice.
- #inspect ⇒ Object
- #matches?(event) ⇒ Boolean
- #next(event) ⇒ Object
- #reset ⇒ Object
Methods inherited from State
Constructor Details
#initialize(context) ⇒ Choice
Returns a new instance of Choice.
363 364 365 366 |
# File 'lib/extensions/rexml/rexml/validation/relaxng.rb', line 363 def initialize context super @choices = [] end |
Instance Method Details
#<<(event) ⇒ Object
374 375 376 |
# File 'lib/extensions/rexml/rexml/validation/relaxng.rb', line 374 def <<( event ) add_event_to_arry( @choices, event ) end |
#expected ⇒ Object
411 412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/extensions/rexml/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 ⇒ Object
424 425 426 |
# File 'lib/extensions/rexml/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) ⇒ Boolean
406 407 408 409 |
# File 'lib/extensions/rexml/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) ⇒ Object
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/extensions/rexml/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 ( @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 |