Sha256: c89327a3eb00f90609f55a694de9c29998261965135f1ee22cca7ae3338ccf20

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

# encoding: UTF-8
#################################################################
# Geocode::TigerLine::Fips
#
# This module contains all the state and country lat longs,
# display names too
#
require 'yaml'

module Geolookup

  module Country
    COUNTRY_NAME_TO_CODE_FILE = "./lib/data/COUNTRY_NAME_TO_CODE.yml"
    COUNTRY_CODE_TO_NAME_FILE = "./lib/data/COUNTRY_CODE_TO_NAME.yml"
    COUNTRY_LAT_LONG_FILE     = "./lib/data/COUNTRY_LAT_LONG.yml"

    @country_name_to_code
    @country_code_to_name
    @country_lat_long
    
    def self.name_to_code(country_name)
      @country_name_to_code ||= Geolookup.load_hash_from_file(COUNTRY_NAME_TO_CODE_FILE)      
      @country_name_to_code[country_name.to_s.upcase]
    end

    def self.code_to_name(country_code)
      @country_code_to_name ||= Geolookup.load_hash_from_file(COUNTRY_CODE_TO_NAME_FILE)
      @country_code_to_name[country_code.to_s.upcase]
    end

    #def self.code_to_lat_long(country_code)
    #  LAT_LONG[country_code.to_s.upcase]
    #end

    def self.name_to_lat_long(country_name) 
      @country_lat_long ||= Geolookup.load_hash_from_file(COUNTRY_LAT_LONG_FILE)
      @country_lat_long[country_name.to_s.upcase]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geolookup-0.5.4 lib/geolookup/country.rb