Skip to content

Commit

Permalink
Allow user to pass String or Twitter::User to Twitter::Streaming::Cli…
Browse files Browse the repository at this point in the history
…ent#site
  • Loading branch information
sferik committed Nov 30, 2013
1 parent 2b20b37 commit e3ad4f2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/twitter/streaming/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def sample(options={}, &block)
# @yield [Twitter::Tweet] A stream of tweets.
def site(*args, &block)
arguments = Arguments.new(args)
request(:get, 'https://sitestream.twitter.com:443/1.1/site.json', arguments.options.merge(:follow => arguments.join(',')), &block)
user_ids = collect_user_ids(arguments)
request(:get, 'https://sitestream.twitter.com:443/1.1/site.json', arguments.options.merge(:follow => user_ids.join(',')), &block)
end

# Streams messages for a single user
Expand Down Expand Up @@ -121,6 +122,22 @@ def default_headers
:user_agent => user_agent,
}
end

def collect_user_ids(users)
user_ids = []
users.flatten.each do |user|
case user
when Integer
user_ids << user
when String
user_ids << user.to_i
when Twitter::User
user_ids << user.id
end
end
user_ids
end

end
end
end

0 comments on commit e3ad4f2

Please sign in to comment.