class Geocoder::Configuration

Constants

OPTIONS

Attributes

data[RW]

Public Class Methods

new() click to toggle source
# File lib/geo-calculator/configuration.rb, line 80
def initialize # :nodoc
  @data = Geocoder::ConfigurationHash.new
  set_defaults
end
set_defaults() click to toggle source
# File lib/geo-calculator/configuration.rb, line 63
def self.set_defaults
  instance.set_defaults
end

Public Instance Methods

configure(options) click to toggle source
# File lib/geo-calculator/configuration.rb, line 76
def configure(options)
  @data.rmerge!(options)
end
set_defaults() click to toggle source
# File lib/geo-calculator/configuration.rb, line 85
def set_defaults

  # geocoding options
  @data[:timeout]      = 3           # geocoding service timeout (secs)
  @data[:lookup]       = :google     # name of street address geocoding service (symbol)
  @data[:ip_lookup]    = :freegeoip  # name of IP address geocoding service (symbol)
  @data[:language]     = :en         # ISO-639 language code
  @data[:http_headers] = {}          # HTTP headers for lookup
  @data[:use_https]    = false       # use HTTPS for lookup requests? (if supported)
  @data[:http_proxy]   = nil         # HTTP proxy server (user:pass@host:port)
  @data[:https_proxy]  = nil         # HTTPS proxy server (user:pass@host:port)
  @data[:api_key]      = nil         # API key for geocoding service
  @data[:cache]        = nil         # cache object (must respond to #[], #[]=, and #keys)
  @data[:cache_prefix] = "geocoder:" # prefix (string) to use for all cache keys

  # exceptions that should not be rescued by default
  # (if you want to implement custom error handling);
  # supports SocketError and TimeoutError
  @data[:always_raise] = []

  # calculation options
  @data[:units]     = :mi      # :mi or :km
  @data[:distances] = :linear  # :linear or :spherical
end