Test Setup Failed
Push — master ( 51a441...b22116 )
by Steven
01:29
created

CsvSource.each()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
1
# frozen_string_literal: true
2
3
require 'csv'
4
5
# Helper class to process CSV files
6
class CsvSource
7
  attr_reader :arrays
8
  
9
  def initialize(file)
10
    @file = file
11
  end
12
  
13
  # returns an array of arrays containing file contents
14
  def read
15
    @arrays = CSV.read(@file)
16
  end
17
18
  # returns a line delimited single string
19
  def to_s
20
    read unless arrays
21
    arrays.map(&:join).join("\n")
22
  end
23
end
24