Class: Polylines::Decoder
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Methods inherited from Base
#decode!, #decoding?, #encode!, #encoding?, #initialize, #step_10, #step_11, #step_2, #step_3, #step_4, #step_5, #step_6, #step_7, #step_8, transform_to_array_of_lat_lng_and_deltas
Constructor Details
This class inherits a constructor from Polylines::Base
Class Method Details
.decode(string) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/polylines/decoder.rb', line 18 def self.decode(string) self.new(string).tap do |decoding| decoding.step_11 decoding.step_10 decoding.step_8 decoding.step_7 decoding.step_6 decoding.step_5 decoding.step_4 decoding.step_3 decoding.step_2 end.current_value end |
.decode_polyline(polyline) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/polylines/decoder.rb', line 3 def self.decode_polyline(polyline) points_with_deltas = transform_to_array_of_lat_lng_and_deltas(polyline) [].tap do |points| points << [points_with_deltas.shift, points_with_deltas.shift] while points_with_deltas.any? points << [ points.last[0] + points_with_deltas.shift, points.last[1] + points_with_deltas.shift ] end end end |