lib/youdao_fanyi/connector.rb in youdao_fanyi-0.1.2.1 vs lib/youdao_fanyi/connector.rb in youdao_fanyi-0.1.2.2
- old
+ new
@@ -25,13 +25,11 @@
@keyfrom = api_key["keyfrom"] || api_key[:keyfrom]
end
def request(word, *options)
options = options.extract_options!
- @q = word.to_s
- @response = self.class.get('', :query => {:q => word}.merge(:key => @key, :keyfrom => @keyfrom))
-# require "pry"
-# binding.pry
+ @q = word.to_s.gsub("_"," ")
+ @response = self.class.get('', :query => {:q => @q}.merge(:key => @key, :keyfrom => @keyfrom))
@results = JSON.load(@response.body)
@error_code, @query = @results['errorCode'], @results['query']
@translation = @error_code == 0 ? @results['translation'].first : YoudaoFanyi::Errors.error_message(@error_code)
self
end