82
83
84
85
86
87
88
89
90
91
|
# File 'lib/pollster/models/question_poll_responses_clean.rb', line 82
def self.from_tsv(tsv)
lines = tsv.split(/(?:\r?\n)+/).reject(&:empty?)
if m = HeaderLineRegex.match(lines[0])
labels = m[:labels].split(/\t/)
rows = lines[1..-1].map { |tsv_line| QuestionPollResponseClean.from_tsv_line_with_labels(tsv_line, labels) }
QuestionPollResponsesClean.new(rows)
else
raise ArgumentError.new("First line of TSV is `#{lines[0]}`, which does not match Pollster::QuestionPollResponsesClean::HeaderLineRegex")
end
end
|