class Google::Directions::Encoder
Attributes
private_key[R]
uri_with_params[R]
Public Class Methods
new(uri_with_params, private_key)
click to toggle source
# File lib/google/directions/encoder.rb, line 9 def initialize(uri_with_params, private_key) @uri_with_params = uri_with_params @private_key = private_key end
Public Instance Methods
encode()
click to toggle source
# File lib/google/directions/encoder.rb, line 14 def encode binary_key = Base64.decode64(private_key.tr('-_','+/')) digest = OpenSSL::Digest.new('sha1') signature = OpenSSL::HMAC.digest(digest, binary_key, uri_with_params) signature = Base64.encode64(signature).tr('+/','-_').tr("\n", '') "#{uri_with_params}&signature=#{signature}" end