map_monkey 0.0.4 → 0.0.5

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.
Files changed (3) hide show
  1. data/lib/map_monkey.rb +48 -40
  2. metadata +9 -7
  3. checksums.yaml +0 -15
data/lib/map_monkey.rb CHANGED
@@ -3,59 +3,67 @@ require 'rexml/document'
3
3
 
4
4
  class Position
5
5
 
6
- attr_accessor :city, :street, :zip
6
+ attr_accessor :city, :street, :zip
7
7
 
8
- def city(city)
9
- self.city
10
- end
8
+ def initialize(city = "", street = "", zip = "")
9
+ @city = city(city)
10
+ @street = street(street)
11
+ @zip = zip(zip)
12
+ end
11
13
 
12
- def street(street)
13
- self.street
14
- end
14
+ def city(city)
15
+ URI.encode(city)
16
+ end
15
17
 
16
- def zip(zip)
17
- self.zip
18
+ def street(street)
19
+ URI.encode(street)
20
+ end
21
+
22
+ def zip(zip)
23
+ URI.encode(zip)
18
24
  end
19
25
 
20
- def lat
21
- url = "http://maps.googleapis.com/maps/api/geocode/xml?address="+self.street+self.zip+self.city+"&sensor=false"
22
- xml_data = Net::HTTP.get_response(URI.parse(url)).body
23
- doc = REXML::Document.new(xml_data)
26
+ def url
27
+ "http://maps.googleapis.com/maps/api/geocode/xml?address=#{@street}#{@zip}#{@city}&sensor=false"
28
+ end
24
29
 
25
- doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
26
- self.lat = ele.text
27
- end
30
+ def get_data
31
+ Net::HTTP.get_response(URI.parse(url)).body
32
+ end
28
33
 
29
- lat
30
- end
34
+ def lat
35
+ doc = REXML::Document.new(get_data)
31
36
 
32
- def lng
33
- url = "http://maps.googleapis.com/maps/api/geocode/xml?address="+self.street+self.zip+self.city+"&sensor=false"
34
- xml_data = Net::HTTP.get_response(URI.parse(url)).body
35
- doc = REXML::Document.new(xml_data)
37
+ doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
38
+ self.lat = ele.text
39
+ end
36
40
 
37
- doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
38
- lng = ele.text
39
- end
41
+ lat
42
+ end
40
43
 
41
- lng
42
- end
44
+ def lng
45
+ doc = REXML::Document.new(get_data)
43
46
 
44
- def lat_lng
45
- url = "http://maps.googleapis.com/maps/api/geocode/xml?address="+self.street+self.zip+self.city+"&sensor=false"
46
- xml_data = Net::HTTP.get_response(URI.parse(url)).body
47
- doc = REXML::Document.new(xml_data)
47
+ doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
48
+ lng = ele.text
49
+ end
48
50
 
49
- doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
50
- lat = ele.text
51
- end
51
+ lng
52
+ end
52
53
 
53
- doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
54
- lng = ele.text
55
- end
54
+ def lat_lng
55
+ doc = REXML::Document.new(get_data)
56
56
 
57
- lat_lng = [lat, lng]
57
+ doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
58
+ lat = ele.text
59
+ end
58
60
 
59
- lat_lng
60
- end
61
+ doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
62
+ lng = ele.text
63
+ end
64
+
65
+ lat_lng = [lat, lng]
66
+
67
+ lat_lng
68
+ end
61
69
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: map_monkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Eric Khoury
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-03-28 00:00:00.000000000 Z
12
+ date: 2013-06-17 00:00:00.000000000 Z
12
13
  dependencies: []
13
- description: Reutrn Google Maps coordinates.
14
+ description: Returns lat and long positions from Google Maps API.
14
15
  email:
15
16
  - ericintheloft@gmail.com
16
17
  executables: []
@@ -20,25 +21,26 @@ files:
20
21
  - lib/map_monkey.rb
21
22
  homepage: https://github.com/eric-khoury/map_monkey
22
23
  licenses: []
23
- metadata: {}
24
24
  post_install_message:
25
25
  rdoc_options: []
26
26
  require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
+ none: false
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  required_rubygems_version: !ruby/object:Gem::Requirement
35
+ none: false
34
36
  requirements:
35
37
  - - ! '>='
36
38
  - !ruby/object:Gem::Version
37
39
  version: '0'
38
40
  requirements: []
39
41
  rubyforge_project:
40
- rubygems_version: 2.0.2
42
+ rubygems_version: 1.8.24
41
43
  signing_key:
42
- specification_version: 4
43
- summary: Google maps API helper.
44
+ specification_version: 3
45
+ summary: Google maps position retriever
44
46
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjVlYTJjOGI1NzhmMDFlZGFhYTRiNzQ5MDU5OGQ1Y2ZkZTg5ZmJjNg==
5
- data.tar.gz: !binary |-
6
- MDdlY2EwOTc3NjVhYjIyYmYyM2NmZDRiOGY3MTRlZGU1NGMwMTQ3NA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NGNhMmZjODMzOTIzYWU1MDVhZGZjNDAzZGU4OWJlYzM3ODU2MzQ3OTNjNzA2
10
- Y2Y0MGIzZjNjMzczMGFkMjAyMzk0NjAxMWFhYThlY2ZhZWFkOTlkODA2MzI2
11
- YjY3ODU4MTRlMmRmMjIwNjhjM2UzMTlkMmRhZWU3NzJiNmI4MGU=
12
- data.tar.gz: !binary |-
13
- MGRhYWEzMWM5YzliODEwYWY4NmZkYTIyYjYxNmJmNWU1OTExYjRhOTE3MDcz
14
- MTZhMjdkMjU4ZGU1NzM2ODZjNmMxMTMzYmI1MjczZmIyMzEzN2E5OGY4MzUw
15
- OWZmM2M3NmViNGExY2I3NmI3ZGE1NmUzMTkzOTA0NjI0ZjkxNTA=