Class: CsvSeparatorDetector
- Inherits:
-
Object
- Object
- CsvSeparatorDetector
- Defined in:
- lib/csv_separator_detector.rb,
lib/csv_separator_detector/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Attribute Summary collapse
-
#csv_text ⇒ Object
readonly
Returns the value of attribute csv_text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(csv_text) ⇒ CsvSeparatorDetector
constructor
A new instance of CsvSeparatorDetector.
- #supported_separators ⇒ Object
Constructor Details
#initialize(csv_text) ⇒ CsvSeparatorDetector
Returns a new instance of CsvSeparatorDetector.
10 11 12 |
# File 'lib/csv_separator_detector.rb', line 10 def initialize(csv_text) @csv_text = csv_text end |
Instance Attribute Details
#csv_text ⇒ Object (readonly)
Returns the value of attribute csv_text.
8 9 10 |
# File 'lib/csv_separator_detector.rb', line 8 def csv_text @csv_text end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 |
# File 'lib/csv_separator_detector.rb', line 14 def call fail ArgumentError, 'Input is nil. Expected it to be a string, with comma-separated lines of text' if csv_text.nil? separator_with_most_columns or fail CsvSeparatorDetector::Error end |
#supported_separators ⇒ Object
20 21 22 |
# File 'lib/csv_separator_detector.rb', line 20 def supported_separators [',', ';', "\t", '|'] end |