Class: Gcloud::Vision::Service
- Inherits:
-
Object
- Object
- Gcloud::Vision::Service
- Defined in:
- lib/gcloud/vision/service.rb
Overview
Represents the service to Vision, exposing the API calls.
Constant Summary collapse
- API =
Alias to the Google Client API module
Google::Apis::VisionV1
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#mocked_service ⇒ Object
Returns the value of attribute mocked_service.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
-
#annotate(requests) ⇒ Object
Returns API::BatchAnnotateImagesResponse.
-
#initialize(project, credentials, retries: nil, timeout: nil) ⇒ Service
constructor
Creates a new Service instance.
- #inspect ⇒ Object
- #service ⇒ Object
Constructor Details
#initialize(project, credentials, retries: nil, timeout: nil) ⇒ Service
Creates a new Service instance.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gcloud/vision/service.rb', line 35 def initialize project, credentials, retries: nil, timeout: nil @project = project @credentials = credentials @service = API::VisionService.new @service..application_name = "gcloud-ruby" @service..application_version = Gcloud::VERSION @service..retries = retries || 3 @service..timeout_sec = timeout if timeout @service. = @credentials.client end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
31 32 33 |
# File 'lib/gcloud/vision/service.rb', line 31 def credentials @credentials end |
#mocked_service ⇒ Object
Returns the value of attribute mocked_service.
50 51 52 |
# File 'lib/gcloud/vision/service.rb', line 50 def mocked_service @mocked_service end |
#project ⇒ Object
Returns the value of attribute project.
30 31 32 |
# File 'lib/gcloud/vision/service.rb', line 30 def project @project end |
Instance Method Details
#annotate(requests) ⇒ Object
Returns API::BatchAnnotateImagesResponse
54 55 56 57 58 59 |
# File 'lib/gcloud/vision/service.rb', line 54 def annotate requests request = API::BatchAnnotateImagesRequest.new(requests: requests) service.annotate_image request rescue Google::Apis::Error => e raise Gcloud::Error.from_error(e) end |
#inspect ⇒ Object
61 62 63 |
# File 'lib/gcloud/vision/service.rb', line 61 def inspect "#{self.class}(#{@project})" end |
#service ⇒ Object
46 47 48 49 |
# File 'lib/gcloud/vision/service.rb', line 46 def service return mocked_service if mocked_service @service end |