Module: Google::Cloud

Defined in:
lib/google-cloud-language.rb,
lib/google/cloud/language.rb,
lib/google/cloud/language/project.rb,
lib/google/cloud/language/service.rb,
lib/google/cloud/language/version.rb,
lib/google/cloud/language/document.rb,
lib/google/cloud/language/annotation.rb,
lib/google/cloud/language/credentials.rb,
lib/google/cloud/language/v1beta1/language_service_pb.rb,
lib/google/cloud/language/v1beta1/language_service_api.rb,
lib/google/cloud/language/v1beta1/language_service_services_pb.rb

Defined Under Namespace

Modules: Language

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.language(project = nil, keyfile = nil, scope: nil, retries: nil, timeout: nil) ⇒ Google::Cloud::Language::Project

Creates a new object for connecting to the Language service. Each call creates a new connection.

For more information on connecting to Google Cloud see the [Authentication Guide](googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).

Examples:

require "google/cloud/language"

language = Google::Cloud.language

topic = language.topic "my-topic"
topic.publish "task completed"

Parameters:

  • project (String) (defaults to: nil)

    Project identifier for the Language service you are connecting to.

  • keyfile (String, Hash) (defaults to: nil)

    Keyfile downloaded from Google Cloud. If file path the file must be readable.

  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See [Using OAuth 2.0 to Access Google APIs](developers.google.com/identity/protocols/OAuth2).

    The default scope is:

  • retries (Integer) (defaults to: nil)

    Number of times to retry requests on server error. The default value is ‘3`. Optional.

  • timeout (Integer) (defaults to: nil)

    Default timeout to use in requests. Optional.

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/google-cloud-language.rb', line 101

def self.language project = nil, keyfile = nil, scope: nil, retries: nil,
                  timeout: nil
  require "google/cloud/language"
  project ||= Google::Cloud::Language::Project.default_project
  if keyfile.nil?
    credentials = Google::Cloud::Language::Credentials.default scope: scope
  else
    credentials = Google::Cloud::Language::Credentials.new(
      keyfile, scope: scope)
  end
  Google::Cloud::Language::Project.new(
    Google::Cloud::Language::Service.new(
      project, credentials, retries: retries, timeout: timeout))
end

Instance Method Details

#language(scope: nil, retries: nil, timeout: nil) ⇒ Google::Cloud::Language::Project

Creates a new object for connecting to the Language service. Each call creates a new connection.

For more information on connecting to Google Cloud see the [Authentication Guide](googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
language = gcloud.language
topic = language.topic "my-topic"
topic.publish "task completed"

The default scope can be overridden with the ‘scope` option:

require "google/cloud"

gcloud  = Google::Cloud.new
platform_scope = "https://www.googleapis.com/auth/cloud-platform"
language = gcloud.language scope: platform_scope

Parameters:

  • scope (String, Array<String>) (defaults to: nil)

    The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. See [Using OAuth 2.0 to Access Google APIs](developers.google.com/identity/protocols/OAuth2).

    The default scope is:

  • retries (Integer) (defaults to: nil)

    Number of times to retry requests on server error. The default value is ‘3`. Optional.

  • timeout (Integer) (defaults to: nil)

    Default timeout to use in requests. Optional.

Returns:



62
63
64
65
66
# File 'lib/google-cloud-language.rb', line 62

def language scope: nil, retries: nil, timeout: nil
  Google::Cloud.language @project, @keyfile, scope: scope,
                                             retries: (retries || @retries),
                                             timeout: (timeout || @timeout)
end