Sha256: 80a6ab8fbcc7d6a77019ed6f71d034a4f6ea688f51dc6fb6a3c53d151cfd8c71

Contents?: true

Size: 507 Bytes

Versions: 1

Compression:

Stored size: 507 Bytes

Contents

module SypexGeo
  class MemoryDatabase < Database
    def setup!
      super

      @db = @file.read(@db_items * @block_len)
      @regions_db = @file.read(@region_size) if @region_size > 0
      @cities_db = @file.read(@city_size) if @city_size > 0
    end

    def search_db(ipn, min, max)
      search_db_chunk(@db, ipn, min, max)
    end

    def read_data(seek, limit, type)
      raw = (type == TYPE_REGION ? @regions_db : @cities_db)[seek, limit]
      Pack.parse(@pack[type], raw)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sypex_geo-0.1.0 lib/sypex_geo/memory_database.rb