Class Jmdict::ImportStreamParser
In: lib/jmdict/import_stream_parser.rb
Parent: REXML::Parsers::StreamParser

Methods

close   full?   more?   parse  

Public Instance methods

[Source]

    # File lib/jmdict/import_stream_parser.rb, line 51
51:   def close
52:     @parser.close
53:   end

[Source]

    # File lib/jmdict/import_stream_parser.rb, line 12
12:   def full?
13:     @listener.full?
14:   end

[Source]

    # File lib/jmdict/import_stream_parser.rb, line 8
 8:   def more?
 9:     not (@end_of_document || @listener.done?)
10:   end

[Source]

    # File lib/jmdict/import_stream_parser.rb, line 16
16:   def parse
17:     # entity string
18:     while true
19:       return if full?
20:       return unless more?
21:       event = @parser.pull
22:       case event[0]
23:       when :end_document
24:         @end_of_document = true
25:         return
26:       when :start_element
27:         attrs = event[2].each do |n, v|
28:           event[2][n] = @parser.unnormalize( v )
29:         end
30:         @listener.tag_start( event[1], attrs )
31:       when :end_element
32:         @listener.tag_end( event[1] )
33:       when :text
34:         normalized = @parser.unnormalize( event[1] )
35:         @listener.text( normalized )
36:       when :processing_instruction
37:         @listener.instruction( *event[1,2] )
38:       when :start_doctype
39:         @listener.doctype( *event[1..-1] )
40:       when :end_doctype
41:         # FIXME: remove this condition for milestone:3.2
42:         @listener.doctype_end if @listener.respond_to? :doctype_end
43:       when :comment, :attlistdecl, :cdata, :xmldecl, :elementdecl
44:         @listener.send( event[0].to_s, *event[1..-1] )
45:       when :entitydecl, :notationdecl
46:         @listener.send( event[0].to_s, event[1..-1] )
47:       end
48:     end
49:   end

[Validate]