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
Class Method Summary collapse
Instance Method Summary collapse
Constructor Details
#initialize(content:) ⇒ Csv
14 15 16 |
# File 'lib/zarby/csv.rb', line 14 def initialize(content:) @content = content || "" end |
Class Method Details
.detect_separator(content) ⇒ String
32 33 34 |
# File 'lib/zarby/csv.rb', line 32 def detect_separator(content) new(content: content).detect_separator end |
Instance Method Details
#call ⇒ String
19 20 21 |
# File 'lib/zarby/csv.rb', line 19 def call valid? ? delimiters[0][0][1] : raise(Zarby::NoColSepDetected) end |
#detect_separator ⇒ String
24 25 26 |
# File 'lib/zarby/csv.rb', line 24 def detect_separator valid? ? delimiters[0][0][1] : raise(Zarby::NoColSepDetected) end |