Module: ReverseGeocoder::Geocoder

Included in:
GeoPlugin, Geonames, Google, IBegin, Numerex
Defined in:
lib/reverse_geocoder/geocoder.rb

Overview

This module is meant to be mixed in to a class to enable it to perform reverse geocoding. The including class needs to implement three hook methods:

request(lat, lng, options) normalize(response) validate_geocoder_options(options)

The request method uses HTTParty syntax to effect the service call and should return its reponse. Exception handling is not required for the HTTP response code.

The normalize method takes the response parameter which behaves like a Hash and maps it to an expected Hash structure. As an alternative

The validate_geocoder_options method is used to validate options provided to a geocoder. The geocoder can throw an exception or snuff out the options as needed.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Mix class methods into the base.



25
26
27
28
# File 'lib/reverse_geocoder/geocoder.rb', line 25

def self.included(base) # :nodoc:
  base.extend(ClassMethods)
  base.send(:include, HTTParty)
end