class Geocoder::Lookup::MaxmindLocal

def results(query)

def results(query)
  if configuration[:file]
    geoip_class = RUBY_PLATFORM == "java" ? JGeoIP : GeoIP
    geoip_instance = geoip_class.new(configuration[:file])
    result =
      if configuration[:package] == :country
        geoip_instance.country(query.to_s)
      else
        geoip_instance.city(query.to_s)
      end
    result.nil? ? [] : [encode_hash(result.to_hash)]
  elsif configuration[:package] == :city
    addr = IPAddr.new(query.text).to_i
    q = "SELECT l.country, l.region, l.city, l.latitude, l.longitude
      FROM maxmind_geolite_city_location l WHERE l.loc_id = (SELECT b.loc_id FROM maxmind_geolite_city_blocks b
      WHERE b.start_ip_num <= #{addr} AND #{addr} <= b.end_ip_num)"
    format_result(q, [:country_name, :region_name, :city_name, :latitude, :longitude])
  elsif configuration[:package] == :country
    addr = IPAddr.new(query.text).to_i
    q = "SELECT country, country_code FROM maxmind_geolite_country
      WHERE start_ip_num <= #{addr} AND #{addr} <= end_ip_num"
    format_result(q, [:country_name, :country_code2])
  end
end