Module: Parser
- Included in:
- Csv2hash
- Defined in:
- lib/csv2hash/parser.rb
Instance Method Summary collapse
Instance Method Details
#fill! ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/csv2hash/parser.rb', line 3 def fill! @data = {}.tap do |data_computed| data_computed[:data] ||= [] data_computed[:data] << {}.tap do |data_parsed| definition.rules.each do |rule| if rule.fetch :mappable x, y = rule.fetch :position if (nested = rule.fetch :nested) data_parsed[nested] ||= {} data_parsed[nested][rule.fetch(:key)] = data_source[x][y] else data_parsed[rule.fetch(:key)] = data_source[x][y] end end end end end end |