Class: Zarby::Csv
- Inherits:
-
Object
- Object
- Zarby::Csv
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/zarby/csv.rb
Overview
this class is used to detect the column separator in a CSV file
Constant Summary collapse
- COMMON_DELIMITERS =
['","', '";"', '":"', '"|"'].freeze
Instance Method Summary collapse
- #call ⇒ String
- #initialize(content:) ⇒ Csv constructor
Constructor Details
#initialize(content:) ⇒ Csv
12 13 14 |
# File 'lib/zarby/csv.rb', line 12 def initialize(content:) @content = content.to_s.each_line.first.to_s.strip end |
Instance Method Details
#call ⇒ String
17 18 19 20 21 22 23 24 |
# File 'lib/zarby/csv.rb', line 17 def call if valid? delimiters[0][0][1] else raise(Zarby::ColSeparatorZarby, "The content to be analyzed must have one of this list as a delimiter: ',' ';' ':' '|'") end end |