module ArrayInFile
Constants
- VERSION
Public Class Methods
read(path)
click to toggle source
Reads contents of file into a string Newlines denote the break between array elements
# File lib/array_in_file.rb, line 7 def self.read (path) array1 = File.open(path, "r").read.split("\n") array1.delete '' return array1 end
write(array_to_write, path)
click to toggle source
Writes an array into a file Newlines denote the break between array elements
# File lib/array_in_file.rb, line 15 def self.write (array_to_write, path) f = File.open(path, 'w') array_to_write.each do |element| f.puts (element.to_s) end f.close end