Class: YoudaoFanyiAPI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/youdao_fanyi_api/client.rb

Constant Summary

PREFIX =
'http://fanyi.youdao.com/openapi.do?'

Instance Method Summary (collapse)

Constructor Details

- (Client) initialize(user_options = {})

Returns a new instance of Client



8
9
10
# File 'lib/youdao_fanyi_api/client.rb', line 8

def initialize(user_options = {})
  @options = YoudaoFanyiAPI.options.merge(user_options)
end

Instance Method Details

- (Object) translate(text, optional = {}) Also known as: t



12
13
14
15
# File 'lib/youdao_fanyi_api/client.rb', line 12

def translate(text, optional = {})
  http_response = get(text, optional)
  json_response = JSON.parse(http_response)
end