module GoogleMapsService::Validator
Validate value that is accepted by Google Maps.
Public Instance Methods
avoid(avoid)
click to toggle source
Validate route restriction. The valid value of route restriction are `tolls`, `highways` or `ferries`.
@param [String, Symbol] avoid Route restriction to be validated.
@raise ArgumentError The route restriction is invalid.
@return [String] Valid route restriction.
# 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)
click to toggle source
Validate travel mode. The valid value of travel mode are `driving`, `walking`, `bicycling` or `transit`.
@param [String, Symbol] mode Travel mode to be validated.
@raise ArgumentError The travel mode is invalid.
@return [String] Valid travel mode.
# 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