7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/udise_school_report_reader/data_reader_base.rb', line 7
def read(lines)
require 'yaml'
template_path = File.join(UdiseSchoolReportReader::ROOT_PATH, 'template.yml')
template = YAML.load_file(template_path)
data = { base_key => template[base_key] }
lines.each_with_index do |line, i|
next_line = lines[i + 1]&.strip
if mapping = self::FIELD_MAPPINGS[line]
if mapping[:is_table]
process_table_data(data, lines[i+1..i+20], mapping)
else
process_simple_field(data, next_line, mapping)
end
end
end
cleanup_data(data)
data
end
|