Completed
Push — master ( ebf929...475333 )
by Marcelo
01:06
created

NamedColumnsParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 13 1
1
require "csv"
2
3
module Koine
4
  module Csv
5
    class NamedColumnsParser < CsvParser
6
      def parse(contents, &block)
7
        contents = contents.split("\n")
8
        titles = contents.shift
9
        column_names = CSV.parse(titles, col_sep: column_separator).first
10
11
        options = {
12
          column_names: column_names,
13
          column_separator: column_separator
14
        }
15
16
        contents = contents.join("\n")
17
        MappedColumnsParser.new(options).parse(contents, &block)
18
      end
19
    end
20
  end
21
end
22