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.



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

def initialize
    @params = {}
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#paramsObject

Returns the value of attribute params.



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

def params
  @params
end

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#parse_response(r) ⇒ Object



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

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

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



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

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