geeo_code 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
1
  class GeeoCode
2
- VERSION = "0.0.2"
2
+ # version number constant
3
+ VERSION = "0.0.3"
3
4
  end
data/lib/geeo_code.rb CHANGED
@@ -3,7 +3,22 @@ require 'open-uri'
3
3
  require 'cgi'
4
4
 
5
5
  require 'geeo_code/version'
6
-
6
+ # GeeoCode is a super simple reverse geocoding wrapper for the Google geocoding apis.
7
+ #
8
+ # Currently it only supports the JSON encoding, but this will probably change in the future
9
+ # in case, for whatever reason, people would rather have it fetched via XML. It really shouln't
10
+ # make any difference since all you get back is a hash of the values.
11
+ #
12
+ # There is only one method you really need to worry about is reverse. This simply takes an address
13
+ # and returns the reverse geocoded data.
14
+ #
15
+ # Simple example:
16
+ #
17
+ # coder = Geeocode.new
18
+ # coder.reverse("6 Woodward Ave, Hilton Head Island, SC")
19
+ #
20
+ # Will return the geocode info for the given address.
21
+ #
7
22
  class GeeoCode
8
23
  GOOGLE_ENDPOINT = "http://maps.googleapis.com/maps/api/geocode/".freeze
9
24
 
@@ -11,14 +26,27 @@ class GeeoCode
11
26
 
12
27
  attr_accessor *VALID_OPTIONS
13
28
 
14
- def initialize( options={} )
29
+ # Valid options are
30
+ # :proxy => true|false
31
+ # :sensor => true|false
32
+ # :format => "json"|"xml"
33
+ #
34
+ # The proxy lets you ignore any environmental `http_proxy` settings.
35
+ # The sensor alerts google to whether or not this is a gps enabled device.
36
+ # The format specifies whether or not we want the results to be parsed from JSON or XML.
37
+ #
38
+ def initialize( args={} )
39
+ options = {:proxy => false, :sensor => false, :format => 'json' }
40
+ options.merge! args
15
41
  options.map {|k,v| send("#{k}=".to_sym, v)}
16
42
  end
17
43
 
18
- def configure
19
- yield self
20
- end
21
-
44
+ # Takes an address, returns a hash with the following:
45
+ #
46
+ # :address => The address info
47
+ # :geometry => Geometry info (lat/long, etc.)
48
+ # :match_type => "Exact or partial match.
49
+ #
22
50
  def reverse(address)
23
51
  begin
24
52
  url = URI.parse("#{GOOGLE_ENDPOINT}#{format}?address=#{CGI::escape(address)}&sensor=#{sensor}")
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Luke van der Hoeven