google_api_directions 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google_api_directions/google_directions.rb +5 -4
- data/lib/google_api_directions/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa2713a83d0592cbad5efae3fc754321a1921d3f
|
4
|
+
data.tar.gz: 97d825b53e959ef756da1914f9c0bc2c4ce446d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c88215f5939691ca59999598fccb1065170ccadaae19a2609e22bcf9635c300d84c263ca2a162d9bc74f787522ff2f28d1c66447ef83645f106207e5f542635
|
7
|
+
data.tar.gz: b9aeb11de01363c8e96e8be29ab0e6abce268bac163c5e6f70a4a7c8fb22529c3c4ce5acf4d04f7bdb718d5f8a39dfcc0dd71f23dd7c3881d2a7a6848ca25e50
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Create a new instance of GoogleDirections.
|
|
26
26
|
g = GoogleApiDirections::GoogleDirections.new
|
27
27
|
|
28
28
|
Let's get the directions. The first paramameter is the origin, the second one is the destination
|
29
|
-
and the third one is the language to be used for the directions and it's optional.
|
29
|
+
and the third one is the language to be used for the directions and it's optional ("en" is default).
|
30
30
|
**Watch out couse Exceptions can be thrown here.**
|
31
31
|
|
32
32
|
result = g.directions("Fittjavägen 1 Norsborg", "Slottsbacken 1 Stockholm", "sv")
|
@@ -7,9 +7,7 @@ module GoogleApiDirections
|
|
7
7
|
class GoogleDirections
|
8
8
|
def initialize(apikey = "")
|
9
9
|
@apikey = ""
|
10
|
-
@apikey = "&key" + apikey unless apikey.empty?
|
11
|
-
|
12
|
-
|
10
|
+
@apikey = "&key=" + apikey unless apikey.empty?
|
13
11
|
@uri = "http://maps.googleapis.com/maps/api/directions/json?origin="
|
14
12
|
@directions = []
|
15
13
|
end
|
@@ -18,8 +16,8 @@ module GoogleApiDirections
|
|
18
16
|
raise ArgumentError, "Argument(s) are missing or are empty" if origin.strip.empty? || destination.strip.empty?
|
19
17
|
|
20
18
|
@directions.clear unless @directions.empty?
|
19
|
+
set_uri(origin, destination, language)
|
21
20
|
|
22
|
-
@uri = @uri + URI::encode(origin) + "&destination=" + URI::encode(destination) + "&language=" + language + "&sensor=false" + @apikey
|
23
21
|
begin
|
24
22
|
resp = Net::HTTP.get_response(URI.parse(@uri))
|
25
23
|
data = resp.body
|
@@ -43,6 +41,9 @@ module GoogleApiDirections
|
|
43
41
|
text.gsub(%r{</?[^>]+?>}, " ")
|
44
42
|
end
|
45
43
|
|
44
|
+
def set_uri(origin, destination, language)
|
45
|
+
@uri = @uri + URI::encode(origin) + "&destination=" + URI::encode(destination) + "&language=" + language + "&sensor=false" + @apikey
|
46
|
+
end
|
46
47
|
end
|
47
48
|
|
48
49
|
end
|