Class: GoogleDistanceMatrix::UrlBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/google_distance_matrix/url_builder.rb,
lib/google_distance_matrix/url_builder/polyline_encoder_buffer.rb

Overview

Takes care of building the url for given matrix

Defined Under Namespace

Classes: PolylineEncoderBuffer

Constant Summary collapse

BASE_URL =
'maps.googleapis.com/maps/api/distancematrix/json'
DELIMITER =
CGI.escape('|')
MAX_URL_SIZE =
2048

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(matrix) ⇒ UrlBuilder

Returns a new instance of UrlBuilder.

Raises:



15
16
17
18
19
# File 'lib/google_distance_matrix/url_builder.rb', line 15

def initialize(matrix)
  @matrix = matrix

  raise InvalidMatrix, matrix if matrix.invalid?
end

Instance Attribute Details

#matrixObject (readonly)

Returns the value of attribute matrix.



12
13
14
# File 'lib/google_distance_matrix/url_builder.rb', line 12

def matrix
  @matrix
end

Instance Method Details

#filtered_urlObject

Returns the URL filtered as the configuration of the matrix dictates

Returns:

  • String



35
36
37
# File 'lib/google_distance_matrix/url_builder.rb', line 35

def filtered_url
  filter_url sensitive_url
end

#sensitive_urlObject

Returns the URL we’ll call Google API with

This URL contains key and signature and is therefor sensitive.

Returns:

  • String

See Also:



28
29
30
# File 'lib/google_distance_matrix/url_builder.rb', line 28

def sensitive_url
  @sensitive_url ||= build_url
end