require'geocoder/results/base'moduleGeocoder::ResultclassMaxmind<Base### Hash mapping service names to names of returned fields.#defself.field_names{:country=>[:country_code,:error],:city=>[:country_code,:region_code,:city_name,:latitude,:longitude,:error],:city_isp_org=>[:country_code,:region_code,:city_name,:postal_code,:latitude,:longitude,:metro_code,:area_code,:isp_name,:organization_name,:error],:omni=>[:country_code,:country_name,:region_code,:region_name,:city_name,:latitude,:longitude,:metro_code,:area_code,:time_zone,:continent_code,:postal_code,:isp_name,:organization_name,:domain,:as_number,:netspeed,:user_type,:accuracy_radius,:country_confidence_factor,:city_confidence_factor,:region_confidence_factor,:postal_confidence_factor,:error]}end### Name of the MaxMind service being used.#defservice_name# it would be much better to infer this from the length of the @data# array, but MaxMind seems to send inconsistent and wide-ranging response# lengths (see https://github.com/alexreisner/geocoder/issues/396)Geocoder.config.maxmind[:service]enddeffield_namesself.class.field_names[service_name]enddefdata_hash@data_hash||=Hash[*field_names.zip(@data).flatten]enddefcoordinates[data_hash[:latitude].to_f,data_hash[:longitude].to_f]enddefcitydata_hash[:city_name]enddefstate# not given by MaxMinddata_hash[:region_name]||data_hash[:region_code]enddefstate_codedata_hash[:region_code]enddefcountry#not given by MaxMinddata_hash[:country_name]||data_hash[:country_code]enddefcountry_codedata_hash[:country_code]enddefpostal_codedata_hash[:postal_code]enddefmethod_missing(method,*args,&block)iffield_names.include?(method)data_hash[method]elsesuperendenddefrespond_to?(method)iffield_names.include?(method)trueelsesuperendendendend