Class: Twitter::Streaming::Client
- Includes:
- Utils
- Defined in:
- lib/twitter/streaming/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
writeonly
Sets the attribute connection.
Attributes inherited from Client
#access_token, #access_token_secret, #consumer_key, #consumer_secret, #dev_environment, #proxy, #timeouts, #user_agent
Instance Method Summary collapse
-
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
- #close ⇒ Object
-
#filter(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Returns public statuses that match one or more filter predicates.
-
#firehose(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Returns all public statuses.
-
#initialize(options = {}) ⇒ Twitter::Streaming::Client
constructor
Initializes a new Client object.
-
#sample(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Returns a small random sample of all public statuses.
-
#site(*follow, options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Streams messages for a set of users.
-
#user(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Streams messages for a single user.
Methods included from Utils
Methods inherited from Client
#credentials, #credentials?, #user_token?
Constructor Details
#initialize(options = {}) ⇒ Twitter::Streaming::Client
Initializes a new Client object
22 23 24 25 |
# File 'lib/twitter/streaming/client.rb', line 22 def initialize( = {}) super @connection = Streaming::Connection.new() end |
Instance Attribute Details
#connection=(value) ⇒ Object (writeonly)
Sets the attribute connection
14 15 16 |
# File 'lib/twitter/streaming/client.rb', line 14 def connection=(value) @connection = value end |
Instance Method Details
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/twitter/streaming/client.rb', line 97 def before_request(&block) if block @before_request = block self elsif instance_variable_defined?(:@before_request) @before_request else proc {} end end |
#close ⇒ Object
108 109 110 |
# File 'lib/twitter/streaming/client.rb', line 108 def close @connection.close end |
#filter(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
At least one predicate parameter (follow, locations, or track) must be specified.
Returns public statuses that match one or more filter predicates
37 38 39 |
# File 'lib/twitter/streaming/client.rb', line 37 def filter( = {}, &) request(:post, "https://stream.twitter.com:443/1.1/statuses/filter.json", , &) end |
#firehose(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
This endpoint requires special permission to access.
Returns all public statuses
49 50 51 |
# File 'lib/twitter/streaming/client.rb', line 49 def firehose( = {}, &) request(:get, "https://stream.twitter.com:443/1.1/statuses/firehose.json", , &) end |
#sample(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Returns a small random sample of all public statuses
58 59 60 |
# File 'lib/twitter/streaming/client.rb', line 58 def sample( = {}, &) request(:get, "https://stream.twitter.com:443/1.1/statuses/sample.json", , &) end |
#site(*follow, options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Site Streams is currently in a limited beta. Access is restricted to whitelisted accounts.
Streams messages for a set of users
74 75 76 77 78 |
# File 'lib/twitter/streaming/client.rb', line 74 def site(*args, &) arguments = Arguments.new(args) user_ids = collect_user_ids(arguments) request(:get, "https://sitestream.twitter.com:443/1.1/site.json", arguments..merge(follow: user_ids.join(",")), &) end |
#user(options = {}) {|Twitter::Tweet, Twitter::Streaming::Event, Twitter::DirectMessage, Twitter::Streaming::FriendList, Twitter::Streaming::DeletedTweet, Twitter::Streaming::StallWarning| ... } ⇒ Object
Streams messages for a single user
92 93 94 |
# File 'lib/twitter/streaming/client.rb', line 92 def user( = {}, &) request(:get, "https://userstream.twitter.com:443/1.1/user.json", , &) end |