module Geocoder

def self.address(query, options = {})


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

def self.config


Read-only access to the singleton's config data.
#
def self.config
  Configuration.instance.data
end

def self.config_for_lookup(lookup_name)


Read-only access to lookup-specific config data.
#
def self.config_for_lookup(lookup_name)
  data = config.clone
  data.reject!{ |key,value| !Configuration::OPTIONS.include?(key) }
  if config.has_key?(lookup_name)
    data.merge!(config[lookup_name])
  end
  data
end

def self.configure(options = nil, &block)


)
:units => :km
:api_key => "2a9fsa983jaslfj982fjasd",
:lookup => :yandex,
:timeout => 5,
Geocoder.configure(

Configuration options should be set by passing a hash:
#
def self.configure(options = nil, &block)
  if !options.nil?
    Configuration.instance.configure(options)
  end
end

def self.coordinates(address, options = {})


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

def self.search(query, options = {})


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