Sha256: 4c15bacedac9939a8832406260441db85f6afb690ce9681613710882e824c717

Contents?: true

Size: 513 Bytes

Versions: 1

Compression:

Stored size: 513 Bytes

Contents

# encoding: utf-8
require 'csv'

module BikePOA
  class MapParser
    EXIBIRESTACAMAPA = /^exibirEstacaMapa\((.*?)\);/m
    CRIAPONTO = /criaPonto\(point,(.*)\) \);/
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bikepoa-tools-0.4.0 lib/bikepoa/map_parser.rb