Class: CSVreadandwrite
- Inherits:
-
Object
- Object
- CSVreadandwrite
- Defined in:
- lib/csv_writer.rb
Instance Method Summary collapse
-
#initialize ⇒ CSVreadandwrite
constructor
A new instance of CSVreadandwrite.
- #read ⇒ Object
- #write(word) ⇒ Object
Constructor Details
#initialize ⇒ CSVreadandwrite
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
#read ⇒ Object
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 |