Class: Twitter::Streaming::Client
- 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
Instance Method Summary collapse
-
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
- #filter(options = {}) {|Twitter::Tweet| ... } ⇒ Object
- #firehose(options = {}) {|Twitter::Tweet| ... } ⇒ Object
-
#initialize(options = {}, &block) ⇒ Twitter::Streaming::Client
constructor
Initializes a new Client object.
- #sample(options = {}) {|Twitter::Tweet| ... } ⇒ Object
- #site(*args) {|Twitter::Tweet| ... } ⇒ Object
- #user(options = {}) {|Twitter::Tweet| ... } ⇒ Object
Methods inherited from Client
#credentials, #credentials?, #user_agent, #user_token?
Constructor Details
#initialize(options = {}, &block) ⇒ Twitter::Streaming::Client
Initializes a new Client object
18 19 20 21 |
# File 'lib/twitter/streaming/client.rb', line 18 def initialize(={}, &block) super @connection = Streaming::Connection.new end |
Instance Attribute Details
#connection=(value) ⇒ Object (writeonly)
Sets the attribute connection
13 14 15 |
# File 'lib/twitter/streaming/client.rb', line 13 def connection=(value) @connection = value end |
Instance Method Details
#before_request(&block) ⇒ Object
Set a Proc to be run when connection established.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/twitter/streaming/client.rb', line 50 def before_request(&block) if block_given? @before_request = block self elsif instance_variable_defined?(:@before_request) @before_request else Proc.new {} end end |
#filter(options = {}) {|Twitter::Tweet| ... } ⇒ Object
24 25 26 |
# File 'lib/twitter/streaming/client.rb', line 24 def filter(={}, &block) request(:post, 'https://stream.twitter.com:443/1.1/statuses/filter.json', , &block) end |
#firehose(options = {}) {|Twitter::Tweet| ... } ⇒ Object
29 30 31 |
# File 'lib/twitter/streaming/client.rb', line 29 def firehose(={}, &block) request(:get, 'https://stream.twitter.com:443/1.1/statuses/firehose.json', , &block) end |
#sample(options = {}) {|Twitter::Tweet| ... } ⇒ Object
34 35 36 |
# File 'lib/twitter/streaming/client.rb', line 34 def sample(={}, &block) request(:get, 'https://stream.twitter.com:443/1.1/statuses/sample.json', , &block) end |
#site(*args) {|Twitter::Tweet| ... } ⇒ Object
39 40 41 42 |
# File 'lib/twitter/streaming/client.rb', line 39 def site(*args, &block) arguments = Arguments.new(args) request(:get, 'https://sitestream.twitter.com:443/1.1/site.json', arguments..merge(:follow => arguments.join(',')), &block) end |
#user(options = {}) {|Twitter::Tweet| ... } ⇒ Object
45 46 47 |
# File 'lib/twitter/streaming/client.rb', line 45 def user(={}, &block) request(:get, 'https://userstream.twitter.com:443/1.1/user.json', , &block) end |