Sha256: 1b6c691d787cc5b6c9f63846cbf88335002f5199ebe9f54186bb75825c9bae5c
Contents?: true
Size: 486 Bytes
Versions: 1
Compression:
Stored size: 486 Bytes
Contents
require 'httpclient' require 'json' require 'geekdict/youdao/config' module GeekDict module Youdao #Youdao API version module_function def translate(word) client = HTTPClient.new query = { keyfrom: APIKEYFROM, key: APIKEY, type: 'data', doctype: 'json',version: APIVERSION, q: word } res = client.get(APIURL, query) res = JSON.parse res.body error_code = res['errorCode'] if error_code == 0 res['basic']['explains'] else [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geekdict-0.0.1 | lib/geekdict/youdao/api.rb |