Class: Gcloud::Translate::Detection::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/gcloud/translate/detection.rb

Overview

# Result

Represents an individual result in a Gcloud::Translate::Detection result.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(confidence, language) ⇒ Result

Returns a new instance of Result.



123
124
125
126
# File 'lib/gcloud/translate/detection.rb', line 123

def initialize confidence, language
  @confidence = confidence
  @language = language
end

Instance Attribute Details

#confidenceFloat (readonly)

The confidence that the language detection result is correct. The closer this value is to 1, the higher the confidence in language detection.

Returns:

  • (Float)

    a value between 0 and 1



111
112
113
# File 'lib/gcloud/translate/detection.rb', line 111

def confidence
  @confidence
end

#languageString (readonly)

The language detected. This is an [ISO 639-1](en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code.

Returns:

  • (String)

    the language code



119
120
121
# File 'lib/gcloud/translate/detection.rb', line 119

def language
  @language
end

Class Method Details

.from_gapi(gapi) ⇒ Object

defined by the Google API Client object.



131
132
133
# File 'lib/gcloud/translate/detection.rb', line 131

def self.from_gapi gapi
  new gapi["confidence"], gapi["language"]
end