class Geocoder::Result::Geoip2

def self.response_attributes

def self.response_attributes
  %w[ip]
end

def address(format = :full)

def address(format = :full)
  s = state.to_s == '' ? '' : ", #{state_code}"
  "#{city}#{s} #{postal_code}, #{country}".sub(/^[ ,]*/, '')
end

def city

def city
  data.fetch('city', {}).fetch('names', {}).fetch('en', '')
end

def coordinates

def coordinates
  [latitude, longitude]
end

def country

def country
  data.fetch('country', {}).fetch('names',{}).fetch('en','')
end

def country_code

def country_code
  data.fetch('country',{}).fetch('iso_code','')
end

def data

def data
  @data.to_hash
end

def latitude

def latitude
  data.fetch('location',{}).fetch('latitude',0.0)
end

def longitude

def longitude
  data.fetch('location',{}).fetch('longitude',0.0)
end

def postal_code

def postal_code
  data.fetch('postal',{}).fetch('code','')
end

def state

def state
  data.fetch('subdivisions',[]).fetch(0,{}).fetch('names',{}).fetch('en','')
end

def state_code

def state_code
  data.fetch('subdivisions',[]).fetch(0,{}).fetch('iso_code','')
end