class Geocoder::Result::Geocodio

def accuracy

def accuracy
  @data['accuracy'].to_f if @data.key?('accuracy')
end

def address_components

def address_components
  @data['address_components'] || {}
end

def city

def city
  address_components["city"]
end

def coordinates

def coordinates
  ['lat', 'lng'].map{ |i| location[i].to_f } if location
end

def country

def country
  # Geocodio supports US and Canada, however they don't return the full
  # country name.
  if country_code == "CA"
    "Canada"
  else
    "United States"
  end
end

def country_code

def country_code
  address_components['country']
end

def formatted_address(format = :full)

def formatted_address(format = :full)
  @data['formatted_address']
end

def location

def location
  @data['location']
end

def number

def number
  address_components["number"]
end

def postdirectional

def postdirectional
  address_components["postdirectional"]
end

def state

def state
  address_components["state"]
end

def street

def street
  address_components["street"]
end

def street_address

def street_address
  [number, address_components["formatted_street"]].compact.join(' ')
end

def suffix

def suffix
  address_components["suffix"]
end

def zip

def zip
  # Postal code is not returned for Canada geocode results
  address_components["zip"] || ""
end