pointy 0.0.1 → 0.0.2

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pointy.rb +16 -13
  3. data/lib/pointy/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2f1a3d3405897e0f0c33e507cd97ffe4c0ca827
4
- data.tar.gz: 1d84ca813e3f761739da87dd9362864759285dab
3
+ metadata.gz: 943e99115573fc3c8796281392156d709e5aaad7
4
+ data.tar.gz: 927301e76c0a9dd1966ab22259f3581a19a76b50
5
5
  SHA512:
6
- metadata.gz: 58c58e86aae685cba6e36c838943adf0ce087cf4008c5edbe356384fb93a7320301636f933a6692c053d71b72b142513b2bfc5e7292f63b9c1bba23f7a2fbcc6
7
- data.tar.gz: 422ab752225df60506f7d932ccade2757b51465691a1a9d585e0f56e4d224c9eda5cc573e461fa46b98f314c52d24874f0ca53592a7c0a54a385d90b294c2b0f
6
+ metadata.gz: bd781242022c91e6119dfee840e97e05d046f39de94bfe9ce7d5e8f5eafc4259190c7219966805261d7d581189898d55ae3e85598c6762dd6a57bc9ac7b2aab8
7
+ data.tar.gz: ad9b6fe9c3bbe458e03d490c243f84a481f67d23d2c6e7db9a47599361bb0fb9a28139f443e5bfa2d7809b81e7b6a1a758b1bff4b24d91e510cfaaf06f66fd96
@@ -16,6 +16,8 @@ module Pointy
16
16
  # long: float
17
17
  # }
18
18
  def self.route(from, to, opts={})
19
+ return if default_params[:key].nil? and opts[:key].nil?
20
+
19
21
  # Format points for Google API
20
22
  opts.merge!({
21
23
  origin: "#{from[:lat]},#{from[:long]}",
@@ -33,22 +35,23 @@ module Pointy
33
35
  legs = route['legs']
34
36
  return if legs.nil? or legs.empty?
35
37
 
36
- points = []
37
- legs.each do |leg|
38
+ # Accumulate all points
39
+ legs.inject([]) do |all_points, leg|
38
40
  steps = leg['steps']
39
- next unless steps
40
- steps.each_with_index do |step, index|
41
- polyline = step['polyline']['points']
42
- decoded_poly = Polylines::Decoder.decode_polyline(polyline)
43
- points += decoded_poly.map do |coord|
44
- {
45
- lat: coord.first,
46
- long: coord.last
47
- }
41
+ if !steps.nil? and !steps.empty?
42
+ steps.each_with_index do |step, index|
43
+ polyline = step['polyline']['points']
44
+ decoded_poly = Polylines::Decoder.decode_polyline(polyline)
45
+ all_points += decoded_poly.map do |coord|
46
+ {
47
+ lat: coord.first,
48
+ long: coord.last
49
+ }
50
+ end
48
51
  end
49
52
  end
50
- end
51
53
 
52
- points
54
+ all_points
55
+ end
53
56
  end
54
57
  end
@@ -1,3 +1,3 @@
1
1
  module Pointy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pointy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Sloey