Permalink
Browse files

update signatures of ToLang::Connector methods to take explicit optio…

…ns parameters
  • Loading branch information...
1 parent b163c31 commit 6897e04de887331bc07eca4ba94ae7211c754844 @jimmycuadra jimmycuadra committed Dec 27, 2010
Showing with 3 additions and 12 deletions.
  1. +3 −12 lib/to_lang/connector.rb
View
@@ -12,28 +12,19 @@ def initialize(key)
@key = key
end
- def request(q, target, *args)
- response = HTTParty.get request_url(q, target, *args)
+ def request(q, target, options = {})
+ response = HTTParty.get request_url(q, target, options)
raise response.parsed_response["error"]["message"] if response.parsed_response["error"] && response.parsed_response["error"]["message"]
response.parsed_response["data"]["translations"][0]["translatedText"]
end
private
- def request_url(q, target, *args)
- options = extract_options(*args)
+ def request_url(q, target, options)
source = options[:from]
url = "#{API_URL}?key=#{@key}&q=#{URI.escape(q)}&target=#{target}"
url += "&source=#{source}" if source
url
end
-
- def extract_options(*args)
- if args.last.is_a? Hash
- args.pop
- else
- {}
- end
- end
end
end

0 comments on commit 6897e04

Please sign in to comment.