Module: GoogleMapsService::Validator
- Defined in:
- lib/google_maps_service/validator.rb
Overview
Validate value that is accepted by Google Maps.
Class Method Summary collapse
-
.avoid(avoid) ⇒ String
Validate route restriction.
-
.travel_mode(mode) ⇒ String
Validate travel mode.
Class Method Details
.avoid(avoid) ⇒ String
Validate route restriction. The valid value of route restriction are tolls
, highways
or ferries
.
32 33 34 35 36 37 |
# File 'lib/google_maps_service/validator.rb', line 32 def avoid(avoid) unless [:tolls, :highways, :ferries].include?(avoid.to_sym) raise ArgumentError, 'Invalid route restriction.' end avoid end |
.travel_mode(mode) ⇒ String
Validate travel mode. The valid value of travel mode are driving
, walking
, bicycling
or transit
.
16 17 18 19 20 21 22 23 |
# File 'lib/google_maps_service/validator.rb', line 16 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 |