Module: Google::Maps::Isochrones
- Defined in:
- lib/google/maps/isochrones.rb,
lib/google/maps/isochrones/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.isochrone_service(version: :v1, transport: :grpc, &block) ⇒ ::Object
Create a new client object for IsochroneService.
-
.isochrone_service_available?(version: :v1, transport: :grpc) ⇒ boolean
Determines whether the IsochroneService service is supported by the current client.
Class Method Details
.isochrone_service(version: :v1, transport: :grpc, &block) ⇒ ::Object
Create a new client object for IsochroneService.
By default, this returns an instance of
Google::Maps::Isochrones::V1::IsochroneService::Client
for a gRPC client for version V1 of the API.
However, you can specify a different API version by passing it in the
version parameter. If the IsochroneService service is
supported by that API version, and the corresponding gem is available, the
appropriate versioned client will be returned.
You can also specify a different transport by passing :rest or :grpc in
the transport parameter.
Raises an exception if the currently installed versioned client gem for the given API version does not support the given transport of the IsochroneService service. You can determine whether the method will succeed by calling isochrone_service_available?.
About IsochroneService
Service for calculating isochrones. An isochrone is an area of reachability from a given origin point within a specified travel time.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/google/maps/isochrones.rb', line 58 def self.isochrone_service version: :v1, transport: :grpc, &block require "google/maps/isochrones/#{version.to_s.downcase}" package_name = Google::Maps::Isochrones .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first service_module = Google::Maps::Isochrones.const_get(package_name).const_get(:IsochroneService) service_module = service_module.const_get(:Rest) if transport == :rest service_module.const_get(:Client).new(&block) end |
.isochrone_service_available?(version: :v1, transport: :grpc) ⇒ boolean
Determines whether the IsochroneService service is supported by the current client. If true, you can retrieve a client object by calling isochrone_service. If false, that method will raise an exception. This could happen if the given API version does not exist or does not support the IsochroneService service, or if the versioned client gem needs an update to support the IsochroneService service.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/google/maps/isochrones.rb', line 82 def self.isochrone_service_available? version: :v1, transport: :grpc require "google/maps/isochrones/#{version.to_s.downcase}" package_name = Google::Maps::Isochrones .constants .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } .first return false unless package_name service_module = Google::Maps::Isochrones.const_get package_name return false unless service_module.const_defined? :IsochroneService service_module = service_module.const_get :IsochroneService if transport == :rest return false unless service_module.const_defined? :Rest service_module = service_module.const_get :Rest end service_module.const_defined? :Client rescue ::LoadError false end |