Class: GoogleMapsPolyline::Decoder
- Inherits:
-
Object
- Object
- GoogleMapsPolyline::Decoder
- Defined in:
- lib/googlemaps_polyline/decoder.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
Instance Method Summary collapse
- #decode_levels ⇒ Object
- #decode_points ⇒ Object
-
#initialize(io) ⇒ Decoder
constructor
A new instance of Decoder.
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
#io ⇒ Object (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_levels ⇒ Object
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_points ⇒ Object
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 |