Class: Csvtree
- Inherits:
-
Object
- Object
- Csvtree
- Defined in:
- lib/csvtrie.rb
Instance Method Summary collapse
- #add_strings(strings) ⇒ Object
- #fill_csv(array_of_words) ⇒ Object
-
#initialize(a = Trie.new) ⇒ Csvtree
constructor
A new instance of Csvtree.
- #read_csv ⇒ Object
Constructor Details
Instance Method Details
#add_strings(strings) ⇒ Object
21 22 23 |
# File 'lib/csvtrie.rb', line 21 def add_strings(strings) strings.each { |string| @a.add_word(string) } end |
#fill_csv(array_of_words) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/csvtrie.rb', line 9 def fill_csv(array_of_words) CSV.open('../test.csv', 'wb') do |csv| csv << %w[id string] array_of_words.each_with_index { |word, index| csv << [index, word] } end end |
#read_csv ⇒ Object
16 17 18 19 |
# File 'lib/csvtrie.rb', line 16 def read_csv strings = CSV.parse(File.read('../fill_words.csv'), headers: true).by_col[1] add_strings(strings) end |