Module: RuVim::Lang::Csv
- Defined in:
- lib/ruvim/lang/csv.rb
Class Method Summary collapse
-
.detect?(buffer) ⇒ Boolean
Detect CSV from buffer content: commas > 0 (and not TSV).
Class Method Details
.detect?(buffer) ⇒ Boolean
Detect CSV from buffer content: commas > 0 (and not TSV)
12 13 14 15 16 |
# File 'lib/ruvim/lang/csv.rb', line 12 def detect?(buffer) sample = (0...[buffer.line_count, 20].min).map { |i| buffer.line_at(i) } commas = sample.sum { |l| l.count(",") } commas > 0 end |