Class: Logaling::GlossarySources::GlossaryCsvSource

Inherits:
Base
  • Object
show all
Defined in:
lib/logaling/glossary_sources/glossary_csv_source.rb

Instance Attribute Summary

Attributes inherited from Base

#glossary, #source_path

Instance Method Summary collapse

Methods inherited from Base

#absolute_path, #eql?, #hash, #initialize, #mtime

Constructor Details

This class inherits a constructor from Logaling::GlossarySources::Base

Instance Method Details

#loadObject



23
24
25
26
27
28
29
30
31
# File 'lib/logaling/glossary_sources/glossary_csv_source.rb', line 23

def load
  glossary_source = []
  CSV.open(absolute_path, "r:utf-8",  {:col_sep => ','}) do |csv|
    csv.each do |row|
      glossary_source << {"source_term" => row[0], "target_term" => row[1], "note" => ""} if row.size >= 2
    end
  end
  glossary_source
end