Sha256: f968ce91ef78174e7ab71032bbcc0f81482ccb817894227e57cb284e24172396

Contents?: true

Size: 418 Bytes

Versions: 1

Compression:

Stored size: 418 Bytes

Contents

require "iso3166_ru/country"

module Iso3166Ru
  class CountryList
    attr_reader :data, :countries, :indexes

    def initialize
      File.open(File.expand_path("../data.dat", __FILE__)) do |f|
        @data = Marshal.load(f)
      end

      @countries = data[0]
      @indexes   = data[1]
    end

    def find_by(query)
      k = query.keys[0]
      q = query[k]
      countries[indexes[k][q]]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iso3166_ru-0.1.1 lib/iso3166_ru/country_list.rb