Module: GoogleMapsService::Validator

Defined in:
lib/google_maps_service/validator.rb

Class Method Summary collapse

Class Method Details

.avoid(avoid) ⇒ Object



16
17
18
19
20
21
# File 'lib/google_maps_service/validator.rb', line 16

def avoid(avoid)
  unless [:tolls, :highways, :ferries].include?(avoid.to_sym)
    raise ArgumentError, 'Invalid route restriction.'
  end
  avoid
end

.travel_mode(mode) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/google_maps_service/validator.rb', line 7

def travel_mode(mode)
  # NOTE(broady): the mode parameter is not validated by the Maps API
  # server. Check here to prevent silent failures.
  unless [:driving, :walking, :bicycling, :transit].include?(mode.to_sym)
    raise ArgumentError, 'Invalid travel mode.'
  end
  mode
end