Class: ReadData
- Inherits:
-
Object
- Object
- ReadData
- Defined in:
- lib/read_data.rb
Instance Attribute Summary collapse
-
#return_val ⇒ Object
Returns the value of attribute return_val.
Instance Method Summary collapse
-
#initialize(file) ⇒ ReadData
constructor
A new instance of ReadData.
- #read_file ⇒ Object
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_val ⇒ Object
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_file ⇒ Object
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 |