Skip to content

Commit

Permalink
Fixing issue philnash#12
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed Carrel committed Nov 3, 2011
1 parent cf764ff commit 1d90810
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/bitly/v3/client.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def info(input)
# #
# Returns the results in the order they were entered # Returns the results in the order they were entered
def lookup(input) def lookup(input)
input = [input] if input.is_a?(String) input = arrayize(input)
query = input.inject([]) { |query, i| query << "url=#{CGI.escape(i)}" } query = input.inject([]) { |query, i| query << "url=#{CGI.escape(i)}" }
query = "/lookup?" + query.join('&') query = "/lookup?" + query.join('&')
response = get(query) response = get(query)
Expand Down Expand Up @@ -109,6 +109,14 @@ def clicks_by_day(input)
end end


private private

def arrayize(arg)
if input.is_a?(String)
[input]
else
input.dup
end
end


def get(method, opts={}) def get(method, opts={})
opts[:query] ||= {} opts[:query] ||= {}
Expand Down Expand Up @@ -138,7 +146,7 @@ def get_single_method(method, input)
end end


def get_method(method, input) def get_method(method, input)
input = [input] if input.is_a? String input = arrayize(input)
query = input.inject([]) do |query,i| query = input.inject([]) do |query,i|
if is_a_short_url?(i) if is_a_short_url?(i)
query << "shortUrl=#{CGI.escape(i)}" query << "shortUrl=#{CGI.escape(i)}"
Expand All @@ -165,4 +173,4 @@ def get_method(method, input)
end end
end end
end end
end end

0 comments on commit 1d90810

Please sign in to comment.