Class: GoogleMapsPolyline::Encoder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Encoder

Returns a new instance of Encoder.



5
6
7
# File 'lib/googlemaps_polyline/encoder.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/encoder.rb', line 9

def io
  @io
end

Instance Method Details

#encode_levels(levels) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/googlemaps_polyline/encoder.rb', line 22

def encode_levels(levels)
  levels.each { |level|
    @io.write(pack_level(level))
  }

  return @io
end

#encode_points(points) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/googlemaps_polyline/encoder.rb', line 11

def encode_points(points)
  plat, plng = 0, 0
  points.each { |lat, lng|
    @io.write(pack_point(lat - plat))
    @io.write(pack_point(lng - plng))
    plat, plng = lat, lng
  }

  return @io
end