Module: Google::Cloud

Defined in:
lib/google-cloud-language.rb,
lib/google/cloud/language.rb,
lib/google/cloud/language/convert.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/v1/language_service_pb.rb,
lib/google/cloud/language/v1/language_service_client.rb,
lib/google/cloud/language/v1beta2/language_service_pb.rb,
lib/google/cloud/language/v1/language_service_services_pb.rb,
lib/google/cloud/language/v1beta2/language_service_client.rb,
lib/google/cloud/language/v1beta2/language_service_services_pb.rb,
lib/google/cloud/language/v1/doc/google/cloud/language/v1/language_service.rb,
lib/google/cloud/language/v1beta2/doc/google/cloud/language/v1beta2/language_service.rb

Defined Under Namespace

Modules: Language

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.language(project = nil, keyfile = nil, scope: nil, timeout: nil, client_config: 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.

Examples:

require "google/cloud"

language = Google::Cloud.language

content = "Star Wars is a great movie. The Death Star is fearsome."
document = language.document content
annotation = document.annotate

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>)

    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.

    The default scope is:

    • "https://www.googleapis.com/auth/cloud-platform"
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

Returns:



104
105
106
107
108
109
110
# File 'lib/google-cloud-language.rb', line 104

def self.language project = nil, keyfile = nil, scope: nil, timeout: nil,
                  client_config: nil
  require "google/cloud/language"
  Google::Cloud::Language.new project: project, keyfile: keyfile,
                              scope: scope, timeout: timeout,
                              client_config: client_config
end

Instance Method Details

#language(scope: nil, timeout: nil, client_config: 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.

Examples:

require "google/cloud"

gcloud = Google::Cloud.new
language = gcloud.language

content = "Star Wars is a great movie. The Death Star is fearsome."
document = language.document content
annotation = document.annotate

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>)

    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.

    The default scope is:

    • "https://www.googleapis.com/auth/cloud-platform"
  • timeout (Integer)

    Default timeout to use in requests. Optional.

  • client_config (Hash)

    A hash of values to override the default behavior of the API client. Optional.

Returns:



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

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