Class: Translate::DetectionResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ DetectionResponse

Returns a new instance of DetectionResponse.



15
16
17
18
19
20
# File 'lib/rtranslate/detection.rb', line 15

def initialize(json)
  @abbrev = json["language"]
  @language = Google::Language::Languages[@abbrev]
  @reliability = json["isReliable"]
  @confidence = json["confidence"]
end

Instance Attribute Details

#abbrevObject (readonly)

Returns the value of attribute abbrev.



10
11
12
# File 'lib/rtranslate/detection.rb', line 10

def abbrev
  @abbrev
end

#confidenceObject (readonly)

Returns the value of attribute confidence.



13
14
15
# File 'lib/rtranslate/detection.rb', line 13

def confidence
  @confidence
end

#languageObject (readonly)

Returns the value of attribute language.



11
12
13
# File 'lib/rtranslate/detection.rb', line 11

def language
  @language
end

#reliabilityObject (readonly)

Returns the value of attribute reliability.



12
13
14
# File 'lib/rtranslate/detection.rb', line 12

def reliability
  @reliability
end

Instance Method Details

#to_sObject



22
23
24
# File 'lib/rtranslate/detection.rb', line 22

def to_s
  abbrev
end