Class: MTranslator::Baidu
- Inherits:
-
Object
- Object
- MTranslator::Baidu
- Defined in:
- lib/m_translator/baidu.rb
Instance Method Summary collapse
-
#initialize(from, to, text) ⇒ Baidu
constructor
A new instance of Baidu.
- #translator ⇒ Object
Constructor Details
#initialize(from, to, text) ⇒ Baidu
Returns a new instance of Baidu.
3 4 5 6 7 8 |
# File 'lib/m_translator/baidu.rb', line 3 def initialize(from,to,text) @url = "https://fanyi.baidu.com/v2transapi" @from = from @to = to p @text = CGI::unescape(text) end |
Instance Method Details
#translator ⇒ Object
10 11 12 13 |
# File 'lib/m_translator/baidu.rb', line 10 def translator rep = RestClient.post @url,req_params,req_headers JSON.parse(rep.body) end |