Class: GoogleDistanceMatrix::Configuration

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/google_distance_matrix/configuration.rb

Overview

Public: Configuration of matrix and it’s request.

Holds configuration used when building API URL.

See developers.google.com/maps/documentation/distancematrix/#RequestParameters for documentation on each configuration.

Constant Summary collapse

ATTRIBUTES =
%w[sensor mode avoid units language]
API_DEFAULTS =
{
  mode: "driving",
  units: "metric"
}.with_indifferent_access

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



32
33
34
35
36
37
38
39
40
# File 'lib/google_distance_matrix/configuration.rb', line 32

def initialize
  self.sensor = false
  self.protocol = "http"
  self.lat_lng_scale = 5

  API_DEFAULTS.each_pair do |attr_name, value|
    self[attr_name] = value
  end
end

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



21
22
23
# File 'lib/google_distance_matrix/configuration.rb', line 21

def cache
  @cache
end

#google_business_api_client_idObject

Returns the value of attribute google_business_api_client_id.



20
21
22
# File 'lib/google_distance_matrix/configuration.rb', line 20

def google_business_api_client_id
  @google_business_api_client_id
end

#google_business_api_private_keyObject

Returns the value of attribute google_business_api_private_key.



20
21
22
# File 'lib/google_distance_matrix/configuration.rb', line 20

def google_business_api_private_key
  @google_business_api_private_key
end

Instance Method Details

#[]=(attr_name, value) ⇒ Object



46
47
48
# File 'lib/google_distance_matrix/configuration.rb', line 46

def []=(attr_name, value)
  public_send "#{attr_name}=", value
end

#to_paramObject



42
43
44
# File 'lib/google_distance_matrix/configuration.rb', line 42

def to_param
  Hash[array_param]
end