class GoogleDistanceMatrix::Configuration

Public: Configuration of matrix and it's request.

Holds configuration used when building API URL.

See developers.google.com/maps/documentation/distance-matrix/intro for documentation on each configuration.

Constants

API_DEFAULTS
ATTRIBUTES

Attributes we'll include building URL for our matrix

Attributes

cache[RW]
cache_key_transform[RW]

Callable object which transform given url to key used in cache @see ClientCache

filter_parameters_in_logged_url[RW]

When logging we filter sensitive parameters

google_api_key[RW]

Google credentials

google_business_api_client_id[RW]

Google credentials

google_business_api_private_key[RW]

Google credentials

lat_lng_scale[RW]

lat_lng_scale is used for each Place when we include it's lat and lng values in the URL. Defaults to 5 decimals, but you can set it lower to save characters in the URL.

Speaking of saving characters. If you use_encoded_polylines all Places which has lat/lng will use encoded set of coordinates using the Encoded Polyline Algorithm. This is particularly useful if you have a large number of origin points, because the URL is significantly shorter when using an encoded polyline. See: developers.google.com/maps/documentation/distance-matrix/intro#RequestParameters

logger[RW]
protocol[RW]

The protocol to use, either http or https

use_encoded_polylines[RW]

lat_lng_scale is used for each Place when we include it's lat and lng values in the URL. Defaults to 5 decimals, but you can set it lower to save characters in the URL.

Speaking of saving characters. If you use_encoded_polylines all Places which has lat/lng will use encoded set of coordinates using the Encoded Polyline Algorithm. This is particularly useful if you have a large number of origin points, because the URL is significantly shorter when using an encoded polyline. See: developers.google.com/maps/documentation/distance-matrix/intro#RequestParameters

Public Class Methods

new() click to toggle source
# File lib/google_distance_matrix/configuration.rb, line 83
def initialize
  API_DEFAULTS.each_pair do |attr_name, value|
    self[attr_name] = begin
                        value.dup
                      rescue StandardError
                        value
                      end
  end
end

Public Instance Methods

[]=(attr_name, value) click to toggle source
# File lib/google_distance_matrix/configuration.rb, line 97
def []=(attr_name, value)
  public_send "#{attr_name}=", value
end
to_param() click to toggle source
# File lib/google_distance_matrix/configuration.rb, line 93
def to_param
  Hash[array_param]
end

Private Instance Methods

array_param() click to toggle source
# File lib/google_distance_matrix/configuration.rb, line 103
def array_param
  out = ATTRIBUTES.map { |attr| [attr, public_send(attr)] }.reject do |attr_and_value|
    attr_and_value[1].nil? || param_same_as_api_default?(attr_and_value)
  end

  out << ['client', google_business_api_client_id] if google_business_api_client_id.present?
  out << ['key', google_api_key] if google_api_key.present?

  out
end
param_same_as_api_default?(param) click to toggle source
# File lib/google_distance_matrix/configuration.rb, line 114
def param_same_as_api_default?(param)
  API_DEFAULTS[param[0]] == param[1]
end