Class: GoogleMapsPolyline::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/googlemaps_polyline/decoder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Decoder

Returns a new instance of Decoder.



5
6
7
# File 'lib/googlemaps_polyline/decoder.rb', line 5

def initialize(io)
  @io = io
end

Instance Attribute Details

#ioObject (readonly)

Returns the value of attribute io.



9
10
11
# File 'lib/googlemaps_polyline/decoder.rb', line 9

def io
  @io
end

Instance Method Details

#decode_levelsObject



29
30
31
32
33
34
35
36
37
# File 'lib/googlemaps_polyline/decoder.rb', line 29

def decode_levels
  levels = []

  until @io.eof?
    levels << read_level(@io)
  end

  return levels
end

#decode_pointsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/googlemaps_polyline/decoder.rb', line 11

def decode_points
  points = []

  until @io.eof?
    lat = read_point(@io)
    lng = read_point(@io)

    unless points.empty?
      lat += points.last[0]
      lng += points.last[1]
    end

    points << [lat, lng]
  end

  return points
end