Class Jmdict::ImportSentenceReferencesListener
In: lib/jmdict/import_sentence_references_listener.rb
Parent: Jmdict::ImportCsvListener

Methods

new   read_line  

Constants

COLUMN_REFERENCE_ID_1 = 0
COLUMN_REFERENCE_ID_2 = 1

Public Class methods

[Source]

   # File lib/jmdict/import_sentence_references_listener.rb, line 6
6:   def initialize(filename, version, maximum_parsed = nil)
7:     super(filename, version, maximum_parsed)
8:   end

Public Instance methods

[Source]

    # File lib/jmdict/import_sentence_references_listener.rb, line 10
10:   def read_line(line)
11:     
12:     begin
13:       
14:       sentence_1 = Sentence.find_by_source_tag(line[COLUMN_REFERENCE_ID_1])
15:       sentence_2 = Sentence.find_by_source_tag(line[COLUMN_REFERENCE_ID_2])
16:       
17:       if sentence_1 && sentence_2
18:         sentence_reference                              = SentenceReference.new
19:         sentence_reference.sentence_id                  = sentence_1.id
20:         sentence_reference.reference_sentence_id        = sentence_2.id
21:         
22:         @records << sentence_reference
23:       else
24:         Rails.logger.error("Insufficient information to create a sentence reference [#{line.inspect}]")
25:       end
26:     rescue => exception
27:       Rails.logger.error(exception)
28:     end
29:     
30:   end

[Validate]