class GoogleMapsAPI::Directions::EncodedPolyline

Attributes

encoded[R]

Public Class Methods

new(encoded) click to toggle source
# File lib/google_maps_api/directions/encoded_polyline.rb, line 4
def initialize(encoded)
  @encoded = encoded
end

Public Instance Methods

coordinates() click to toggle source
# File lib/google_maps_api/directions/encoded_polyline.rb, line 8
def coordinates
  @coordinates ||= decode
  @coordinates
end
to_s() click to toggle source
# File lib/google_maps_api/directions/encoded_polyline.rb, line 13
def to_s
  encoded
end

Private Instance Methods

decode() click to toggle source
# File lib/google_maps_api/directions/encoded_polyline.rb, line 19
def decode
  begin
    require "polylines" unless defined?(Polylines)
    array = Polylines::Decoder.decode_polyline(encoded)
    return array.collect do |c|
      GoogleMapsAPI::Core::Coordinate.from_array(c)
    end
  rescue LoadError
    raise "You need to install and require the 'polylines' (https://rubygems.org/gems/polylines) gem in your Gemfile if you want to use this method"
  end
end