Class: GoogleMapsPlatform::DistanceMatrixElementStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/google_maps_platform/models/distance_matrix_element_status.rb

Overview

  • OK indicates the response contains a valid result. - NOT_FOUND

indicates that the origin and/or destination of this pairing could not be geocoded. - ZERO_RESULTS indicates no route could be found between the origin and destination. - MAX_ROUTE_LENGTH_EXCEEDED indicates the requested route is too long and cannot be processed.

Constant Summary collapse

DISTANCE_MATRIX_ELEMENT_STATUS =
[
  # TODO: Write general description for OK

  OK = 'OK'.freeze,

  # TODO: Write general description for NOT_FOUND

  NOT_FOUND = 'NOT_FOUND'.freeze,

  # TODO: Write general description for ZERO_RESULTS

  ZERO_RESULTS = 'ZERO_RESULTS'.freeze,

  # TODO: Write general description for MAX_ROUTE_LENGTH_EXCEEDED

  MAX_ROUTE_LENGTH_EXCEEDED = 'MAX_ROUTE_LENGTH_EXCEEDED'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = OK) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/google_maps_platform/models/distance_matrix_element_status.rb', line 33

def self.from_value(value, default_value = OK)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'ok' then OK
  when 'not_found' then NOT_FOUND
  when 'zero_results' then ZERO_RESULTS
  when 'max_route_length_exceeded' then MAX_ROUTE_LENGTH_EXCEEDED
  else
    default_value
  end
end

.validate(value) ⇒ Object



27
28
29
30
31
# File 'lib/google_maps_platform/models/distance_matrix_element_status.rb', line 27

def self.validate(value)
  return false if value.nil?

  DISTANCE_MATRIX_ELEMENT_STATUS.include?(value)
end