Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow speed_unit to be passed to request #7

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/google_maps_service/apis/roads.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def snap_to_roads(path, interpolate: false)
# by the snap_to_roads function. You can pass up to 100 Place IDs.
#
# @return [Array] Array of speed limits.
def speed_limits(place_ids)
def speed_limits(place_ids, units: 'KPH')
params = GoogleMapsService::Convert.as_list(place_ids).map { |place_id| ['placeId', place_id] }
params << ['units', units] if units.match(/^mph$/i)

return get('/v1/speedLimits', params,
base_url: ROADS_BASE_URL,
Expand All @@ -91,12 +92,13 @@ def speed_limits(place_ids)
#
# @return [Hash] A hash with both a list of speed limits and a list of the snapped
# points.
def snapped_speed_limits(path)
def snapped_speed_limits(path, units: 'KPH')
path = GoogleMapsService::Convert.waypoints(path)

params = {
path: path
}
path: path,
units: (units if units.match(/^mph$/i))
}.reject {|k,v| v.nil?}

return get('/v1/speedLimits', params,
base_url: ROADS_BASE_URL,
Expand Down