Sha256: 90de1045fc685ddbc2982e19f02f25845f87e34906dae453f290337aa8118848

Contents?: true

Size: 438 Bytes

Versions: 4

Compression:

Stored size: 438 Bytes

Contents

# encoding: utf-8
require 'csv'

module BikePOA
  class MapParser
    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 _ _]
        Hash[fields.zip(line_data)].delete_if { |key,value| key == '_' }
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bikepoa-tools-0.3.1 lib/bikepoa/map_parser.rb
bikepoa-tools-0.3.0 lib/bikepoa/map_parser.rb
bikepoa-tools-0.2.0 lib/bikepoa/map_parser.rb
bikepoa-tools-0.1.0 lib/bikepoa/map_parser.rb