Class: CSVPlusPlus::Reader::CSV

Inherits:
Reader
  • Object
show all
Extended by:
T::Generic, T::Sig
Defined in:
lib/csv_plus_plus/reader/csv.rb

Overview

Reads a CSV file

Constant Summary collapse

CellValue =
type_member { { fixed: ::String } }

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ CSV

Open a CSV outputter to the output_filename specified by the Options

Parameters:

  • options (Options)

    The supplied options.



18
19
20
21
22
23
24
25
26
# File 'lib/csv_plus_plus/reader/csv.rb', line 18

def initialize(options)
  super()

  @options = options
  @cell_values = ::T.let(
    read_csv(@options.output_filename),
    ::T::Array[::T::Array[::T.nilable(::CSVPlusPlus::Reader::CSV::CellValue)]]
  )
end

Instance Method Details

#value_at(cell) ⇒ CellValue?

Get the current value at the cell‘s location.

Parameters:

Returns:



34
35
36
# File 'lib/csv_plus_plus/reader/csv.rb', line 34

def value_at(cell)
  @cell_values[cell.row_index]&.[](cell.index)
end