| Total Complexity | 5 |
| Total Lines | 20 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # frozen_string_literal: true |
||
| 6 | class CsvSource |
||
| 7 | attr_reader :arrays |
||
| 8 | attr_reader :file |
||
| 9 | |||
| 10 | def initialize(file) |
||
| 11 | @file = file |
||
| 12 | end |
||
| 13 | |||
| 14 | # returns an array of arrays containing file contents |
||
| 15 | def read |
||
| 16 | raise FileNotFoundException.new I18n.t :file_not_found unless File.exist? file |
||
| 17 | @arrays = CSV.read(file) |
||
| 18 | end |
||
| 19 | |||
| 20 | # returns a line delimited single string |
||
| 21 | def to_s |
||
| 22 | read unless arrays |
||
| 23 | arrays.map(&:join).join("\n") |
||
| 24 | end |
||
| 25 | end |
||
| 26 |