# File lib/geoip.rb, line 172
  def country(hostname)
    if (@database_type == GEOIP_CITY_EDITION_REV0 ||
        @database_type == GEOIP_CITY_EDITION_REV1)
      return city(hostname)
    end

    ip = lookup_ip(hostname)

    # Convert numeric IP address to an integer
    ipnum = iptonum(ip)

    if (@database_type != GEOIP_COUNTRY_EDITION &&
        @database_type != GEOIP_PROXY_EDITION &&
        @database_type != GEOIP_NETSPEED_EDITION)
      throw "Invalid GeoIP database type, can't look up Country by IP"
    end

    code = (seek_record(ipnum) - COUNTRY_BEGIN)

    Country.new(
      hostname,                   # Requested hostname
      ip,                         # Ip address as dotted quad
      code,                       # GeoIP's country code
      CountryCode[code],          # ISO3166-1 alpha-2 code
      CountryCode3[code],         # ISO3166-2 alpha-3 code
      CountryName[code],          # Country name, per ISO 3166
      CountryContinent[code]      # Continent code.
    )
  end