lib/bikepoa/map_parser.rb in bikepoa-tools-0.3.1 vs lib/bikepoa/map_parser.rb in bikepoa-tools-0.4.0

- old
+ new

@@ -1,14 +1,15 @@ # encoding: utf-8 require 'csv' module BikePOA class MapParser + EXIBIRESTACAMAPA = /^exibirEstacaMapa\((.*?)\);/m CRIAPONTO = /criaPonto\(point,(.*)\) \);/ def parse(content) - content.scan(CRIAPONTO).map do |station_match| - line_data = CSV.parse_line(station_match.first, quote_char: "'") - fields = %w[id name address _ _ _ online status size available _ _] + content.scan(EXIBIRESTACAMAPA).map do |station_match| + line_data = CSV.parse_line(station_match.first.gsub(/\r?\n/,''), quote_char: "\"") + fields = %w[_ _ _ name id online status available size address] Hash[fields.zip(line_data)].delete_if { |key,value| key == '_' } end end end end