Class: RubyUtils::FileReader
- Inherits:
-
Object
- Object
- RubyUtils::FileReader
- Defined in:
- lib/ruby_utils/file_reader.rb
Overview
Simple file reader using the csv library to read a csv file requires csv
Instance Attribute Summary collapse
-
#data ⇒ Array
readonly
An array containing the read data.
Instance Method Summary collapse
-
#initialize(filename, delimiter) ⇒ FileReader
constructor
initialization.
Constructor Details
#initialize(filename, delimiter) ⇒ FileReader
initialization
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ruby_utils/file_reader.rb', line 18 def initialize(filename, delimiter) begin @data = CSV.read(filename, col_sep: delimiter) # remove nil entries @data.each { |line| line.compact! } rescue StandardError => e raise IOError, e..concat(".").red end end |
Instance Attribute Details
#data ⇒ Array (readonly)
Returns an array containing the read data.
12 13 14 |
# File 'lib/ruby_utils/file_reader.rb', line 12 def data @data end |