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

CsvSource   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A to_s() 0 4 2
A initialize() 0 3 1
A read() 0 3 1
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