Class: ReadData

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ ReadData

Returns a new instance of ReadData.



7
8
9
# File 'lib/read_data.rb', line 7

def initialize(file)
  @file = file
end

Instance Attribute Details

#return_valObject

Returns the value of attribute return_val.



5
6
7
# File 'lib/read_data.rb', line 5

def return_val
  @return_val
end

Instance Method Details

#read_fileObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/read_data.rb', line 11

def read_file()
 return unless File.exists?(@file)
 return_val = []

 CSV.foreach(@file, headers: true, quote_char: '"', col_sep: ',') do |row|
   return_val << row
 end

 return_val
end