Class Jmdict::ImportCsvParser
In: lib/jmdict/import_csv_parser.rb
Parent: Object

Methods

close   full?   more?   new   parse  

Included Modules

Jmdict::Message

Public Class methods

[Source]

    # File lib/jmdict/import_csv_parser.rb, line 7
 7:   def initialize(source_location, listener)
 8:     @listener        = listener
 9:     @source_location = source_location
10:     
11:     options          = {
12:       :col_sep => ';',
13:       :encoding => 'UTF8',
14:     }
15:     read_only        = 'r'
16:     @parser          = FasterCSV.open(@source_location, read_only, options)
17:   end

Public Instance methods

[Source]

    # File lib/jmdict/import_csv_parser.rb, line 46
46:   def close
47:     @parser.close
48:   end

[Source]

    # File lib/jmdict/import_csv_parser.rb, line 25
25:   def full?
26:     @listener.full?
27:   end

[Source]

    # File lib/jmdict/import_csv_parser.rb, line 21
21:   def more?
22:     not (@end_of_document || @listener.done?)
23:   end

[Source]

    # File lib/jmdict/import_csv_parser.rb, line 29
29:   def parse
30:     # entity string
31:     while not @end_of_document
32:       return if full?
33:       return unless more?
34:       (status, results) = pull
35:       case status
36:         when :eof
37:           @end_of_document = true
38:         when :read_line
39:           @listener.read_line( results )
40:         else
41:           @end_of_document = true
42:       end
43:     end
44:   end

[Validate]