Class: MTranslator::Youdao

Inherits:
Object
  • Object
show all
Defined in:
lib/m_translator/youdao.rb

Instance Method Summary collapse

Constructor Details

#initialize(from, to, text) ⇒ Youdao

初始化



4
5
6
7
8
9
10
11
12
# File 'lib/m_translator/youdao.rb', line 4

def initialize(from, to, text)
  @url = "http://fanyi.youdao.com/translate_o?smartresult=dict&smartresult=rule"
  @from = from
  @to = to
  @text = text
  @u = "fanyideskweb"
  @c = "n%A-rKaT5fb[Gy?;N5@Tj"
  @f = "#{ctime}"+"#{rand(10 + 1)}"
end

Instance Method Details

#translatorObject



14
15
16
17
# File 'lib/m_translator/youdao.rb', line 14

def translator
  rep = RestClient.post @url,req_params,req_headers
  JSON.parse(rep.body)
end