map_monkey 0.0.5 → 0.0.6

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 (2) hide show
  1. data/lib/map_monkey.rb +5 -65
  2. metadata +5 -5
data/lib/map_monkey.rb CHANGED
@@ -1,69 +1,9 @@
1
- require 'net/http'
2
- require 'rexml/document'
1
+ require 'map_monkey/position'
2
+ module MapMonkey
3
3
 
4
- class Position
5
-
6
- attr_accessor :city, :street, :zip
7
-
8
- def initialize(city = "", street = "", zip = "")
9
- @city = city(city)
10
- @street = street(street)
11
- @zip = zip(zip)
12
- end
13
-
14
- def city(city)
15
- URI.encode(city)
16
- end
17
-
18
- def street(street)
19
- URI.encode(street)
20
- end
21
-
22
- def zip(zip)
23
- URI.encode(zip)
24
- end
25
-
26
- def url
27
- "http://maps.googleapis.com/maps/api/geocode/xml?address=#{@street}#{@zip}#{@city}&sensor=false"
28
- end
29
-
30
- def get_data
31
- Net::HTTP.get_response(URI.parse(url)).body
32
- end
33
-
34
- def lat
35
- doc = REXML::Document.new(get_data)
36
-
37
- doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
38
- self.lat = ele.text
4
+ class << self
5
+ def new(params = {})
6
+ MapMonkey.new(params)
39
7
  end
40
-
41
- lat
42
- end
43
-
44
- def lng
45
- doc = REXML::Document.new(get_data)
46
-
47
- doc.elements.each('GeocodeResponse/result/geometry/location/lng') do |ele|
48
- lng = ele.text
49
- end
50
-
51
- lng
52
- end
53
-
54
- def lat_lng
55
- doc = REXML::Document.new(get_data)
56
-
57
- doc.elements.each('GeocodeResponse/result/geometry/location/lat') do |ele|
58
- lat = ele.text
59
- end
60
-
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
8
  end
69
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: map_monkey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-17 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: Returns lat and long positions from Google Maps API.
14
+ description: Returns lat and long coordinates from Google Maps API.
15
15
  email:
16
- - ericintheloft@gmail.com
16
+ - khoury@live.se
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
@@ -39,7 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  version: '0'
40
40
  requirements: []
41
41
  rubyforge_project:
42
- rubygems_version: 1.8.24
42
+ rubygems_version: 1.8.25
43
43
  signing_key:
44
44
  specification_version: 3
45
45
  summary: Google maps position retriever