Class: MTranslator::Google
- Inherits:
-
Object
- Object
- MTranslator::Google
- Defined in:
- lib/m_translator/google.rb
Instance Method Summary collapse
-
#initialize(from, to, text) ⇒ Google
constructor
A new instance of Google.
- #translator ⇒ Object
Constructor Details
#initialize(from, to, text) ⇒ Google
Returns a new instance of Google.
3 4 5 6 7 8 |
# File 'lib/m_translator/google.rb', line 3 def initialize(from,to,text) @url = "https://translate.google.cn/translate_a/single" @from = from @to = to @text = CGI::unescape(text) end |
Instance Method Details
#translator ⇒ Object
10 11 12 13 |
# File 'lib/m_translator/google.rb', line 10 def translator rep = RestClient.get "#{@url}?#{req_params}" JSON.parse(rep.body) end |