Total Complexity | 4 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # frozen_string_literal: true |
||
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 |