Class: BikePOA::MapParser

Inherits:
Object
  • Object
show all
Defined in:
lib/bikepoa/map_parser.rb

Constant Summary collapse

EXIBIRESTACAMAPA =
/^exibirEstacaMapa\((.*?)\);/m
CRIAPONTO =
/criaPonto\(point,(.*)\) \);/

Instance Method Summary collapse

Instance Method Details

#parse(content) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/bikepoa/map_parser.rb', line 8

def parse(content)
  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