diff --git a/lib/geocoder/results/geoip2.rb b/lib/geocoder/results/geoip2.rb index 034f77f831b83ec9c7595663dc189e0bee02337b..5cf9e9da342cab21a5cf5e157c8c4492e7fda65f 100644 --- a/lib/geocoder/results/geoip2.rb +++ b/lib/geocoder/results/geoip2.rb @@ -13,35 +13,35 @@ module Geocoder end def latitude - @data.fetch('location',{}).fetch('latitude',0.0) + data.fetch('location',{}).fetch('latitude',0.0) end def longitude - @data.fetch('location',{}).fetch('longitude',0.0) + data.fetch('location',{}).fetch('longitude',0.0) end def city - @data.fetch('city', {}).fetch('names', {}).fetch('en', '') + data.fetch('city', {}).fetch('names', {}).fetch('en', '') end def state - @data.fetch('subdivisions',[]).fetch(0,{}).fetch('names',{}).fetch('en','') + data.fetch('subdivisions',[]).fetch(0,{}).fetch('names',{}).fetch('en','') end def state_code - @data.fetch('subdivisions',[]).fetch(0,{}).fetch('iso_code','') + data.fetch('subdivisions',[]).fetch(0,{}).fetch('iso_code','') end def country - @data.fetch('country', {}).fetch('names',{}).fetch('en','') + data.fetch('country', {}).fetch('names',{}).fetch('en','') end def country_code - @data.fetch('country',{}).fetch('iso_code','') + data.fetch('country',{}).fetch('iso_code','') end def postal_code - @data.fetch('postal',{}).fetch('code','') + data.fetch('postal',{}).fetch('code','') end def self.response_attributes @@ -53,6 +53,12 @@ module Geocoder @data[a] end end + + private + + def data + @data.to_hash + end end end end