Class | REXML::Parsers::PullEvent |
In: |
lib/rexml/parsers/pullparser.rb
|
Parent: | Object |
A parsing event. The contents of the event are accessed as an +Array?, and the type is given either by the …? methods, or by accessing the type accessor. The contents of this object vary from event to event, but are identical to the arguments passed to +StreamListener+s for each event.
The type of this event. Will be one of :tag_start, :tag_end, :text, :processing_instruction, :comment, :doctype, :attlistdecl, :entitydecl, :notationdecl, :entity, :cdata, :xmldecl, or :error.
# File lib/rexml/parsers/pullparser.rb, line 94 94: def initialize(arg) 95: @contents = arg 96: end
# File lib/rexml/parsers/pullparser.rb, line 98 98: def []( start, endd=nil) 99: if start.kind_of? Range 100: @contents.slice( start.begin+1 .. start.end ) 101: elsif start.kind_of? Numeric 102: if endd.nil? 103: @contents.slice( start+1 ) 104: else 105: @contents.slice( start+1, endd ) 106: end 107: else 108: raise "Illegal argument #{start.inspect} (#{start.class})" 109: end 110: end
Due to the wonders of DTDs, an entity declaration can be just about anything. There‘s no way to normalize it; you‘ll have to interpret the content yourself. However, the following is true:
Content: [ String text ]
# File lib/rexml/parsers/pullparser.rb, line 163 163: def entitydecl? 164: @contents[0] == :entitydecl 165: end
# File lib/rexml/parsers/pullparser.rb, line 187 187: def error? 188: @contents[0] == :error 189: end
# File lib/rexml/parsers/pullparser.rb, line 191 191: def inspect 192: @contents[0].to_s + ": " + @contents[1..-1].inspect 193: end