Skip to content
Browse files

Fixing issue #12

  • Loading branch information...
1 parent cf764ff commit 1d908105fc4d2492b0772f594237fbb7e3126f46 Ed Carrel committed Nov 3, 2011
Showing with 11 additions and 3 deletions.
  1. +11 −3 lib/bitly/v3/client.rb
View
14 lib/bitly/v3/client.rb
@@ -63,7 +63,7 @@ def info(input)
#
# Returns the results in the order they were entered
def lookup(input)
- input = [input] if input.is_a?(String)
+ input = arrayize(input)
query = input.inject([]) { |query, i| query << "url=#{CGI.escape(i)}" }
query = "/lookup?" + query.join('&')
response = get(query)
@@ -109,6 +109,14 @@ def clicks_by_day(input)
end
private
+
+ def arrayize(arg)
+ if input.is_a?(String)
+ [input]
+ else
+ input.dup
+ end
+ end
def get(method, opts={})
opts[:query] ||= {}
@@ -138,7 +146,7 @@ def get_single_method(method, input)
end
def get_method(method, input)
- input = [input] if input.is_a? String
+ input = arrayize(input)
query = input.inject([]) do |query,i|
if is_a_short_url?(i)
query << "shortUrl=#{CGI.escape(i)}"
@@ -165,4 +173,4 @@ def get_method(method, input)
end
end
end
-end
+end

0 comments on commit 1d90810

Please sign in to comment.
Something went wrong with that request. Please try again.