Class: Smartdict::Drivers::GoogleTranslateDriver

Inherits:
AbstractDriver show all
Defined in:
lib/smartdict/drivers/google_translate_driver.rb

Overview

The translation driver for Google Translate service.

Constant Summary collapse

USER_AGENT =

Pretend being Firefox :)

"Mozilla/5.0 (X11; U; Linux x86_64; ru; rv:1.9.1.16) Gecko/20110429 Iceweasel/3.5.16 (like Firefox/3.5.1623123)"
HOST =

Host of Google Translate service.

"translate.google.com"

Instance Attribute Summary

Attributes inherited from AbstractDriver

#from_lang, #to_lang, #transcription, #translated, #word

Instance Method Summary collapse

Methods inherited from AbstractDriver

#build_translation, #initialize, set_name, translate

Constructor Details

This class inherits a constructor from Smartdict::Drivers::AbstractDriver

Instance Method Details

#translateObject

Sets translation and transcription. GoogleTranslate doesn’t provide transcription, so it’s nil.



15
16
17
18
# File 'lib/smartdict/drivers/google_translate_driver.rb', line 15

def translate
  self.translated = response_to_hash(get_response)
  self.transcription = nil
end