Class: CSVreadandwrite

Inherits:
Object
  • Object
show all
Defined in:
lib/csv_writer.rb

Instance Method Summary collapse

Constructor Details

#initializeCSVreadandwrite

Returns a new instance of CSVreadandwrite.



4
5
6
# File 'lib/csv_writer.rb', line 4

def initialize
  @path = '../data.csv'
end

Instance Method Details

#readObject



14
15
16
# File 'lib/csv_writer.rb', line 14

def read
  CSV.read(@path)
end

#write(word) ⇒ Object



8
9
10
11
12
# File 'lib/csv_writer.rb', line 8

def write(word)
  CSV.open(@path, 'a') do |csv|
    csv << [word]
  end
end