module Geocoder

def self.configure(&block)


Provides convenient access to the Configuration singleton.
#
def self.configure(&block)
  if block_given?
    block.call(Configuration.instance)
  else
    Configuration.instance
  end
end

def address(query, options = {})


or IP address (string).
Look up the address of the given coordinates ([lat,lon])
#
def address(query, options = {})
  if (results = search(query, options)).size > 0
    results.first.address
  end
end

def cache


The working Cache object, or +nil+ if none configured.
#
def cache
  if @cache.nil? and store = Configuration.cache
    @cache = Cache.new(store, Configuration.cache_prefix)
  end
  @cache
end

def coordinates(address, options = {})


Look up the coordinates of the given street or IP address.
#
def coordinates(address, options = {})
  if (results = search(address, options)).size > 0
    results.first.coordinates
  end
end

def search(query, options = {})


Search for information about an address or a set of coordinates.
#
def search(query, options = {})
  query = Geocoder::Query.new(query, options) unless query.is_a?(Geocoder::Query)
  query.blank? ? [] : query.execute
end