Class: Geocoder

Inherits:
Object
  • Object
show all
Defined in:
lib/kamelopard/geocode.rb

Overview

Geocoder base class. You should use a subclass. It is your responsibility to ensure you comply with all API licensing and usage requirements. Kamelopard won't do it for you.

Direct Known Subclasses

GoogleGeocoder, MapquestGeocoder, YahooGeocoder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGeocoder

Returns a new instance of Geocoder.


15
16
17
# File 'lib/kamelopard/geocode.rb', line 15

def initialize
    @params = {}
end

Instance Attribute Details

#hostObject

Returns the value of attribute host


14
15
16
# File 'lib/kamelopard/geocode.rb', line 14

def host
  @host
end

#paramsObject

Returns the value of attribute params


14
15
16
# File 'lib/kamelopard/geocode.rb', line 14

def params
  @params
end

#pathObject

Returns the value of attribute path


14
15
16
# File 'lib/kamelopard/geocode.rb', line 14

def path
  @path
end

Instance Method Details

#parse_response(r) ⇒ Object


29
30
31
# File 'lib/kamelopard/geocode.rb', line 29

def parse_response(r)
    raise "Unimplemented -- use a child of the Geocoder class"
end

#processParam(value, key = 'location') ⇒ Object


19
20
21
22
23
24
25
26
27
# File 'lib/kamelopard/geocode.rb', line 19

def processParam(value, key = 'location')
    return ["#{key}=#{value}"] if key == 'key'
    if value.kind_of? Hash then
        p = value.map { |k, v| "#{CGI.escape(k)}=#{CGI.escape(v)}" }
    else
        p = ["#{CGI.escape(key)}=#{CGI.escape(value)}"]
    end
    return p
end