Class: Twitter::Streaming::Client

Inherits:
Client
  • Object
show all
Defined in:
lib/twitter/streaming/client.rb

Instance Attribute Summary collapse

Attributes inherited from Client

#access_token, #access_token_secret, #consumer_key, #consumer_secret

Instance Method Summary collapse

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(options={}, &block)
  super
  @connection = Streaming::Connection.new
end

Instance Attribute Details

#connection=(value) ⇒ Object (writeonly)

Sets the attribute connection

Parameters:

  • value

    the value to set the attribute connection to.



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

Yields:



24
25
26
# File 'lib/twitter/streaming/client.rb', line 24

def filter(options={}, &block)
  request(:post, 'https://stream.twitter.com:443/1.1/statuses/filter.json', options, &block)
end

#firehose(options = {}) {|Twitter::Tweet| ... } ⇒ Object

Yields:



29
30
31
# File 'lib/twitter/streaming/client.rb', line 29

def firehose(options={}, &block)
  request(:get, 'https://stream.twitter.com:443/1.1/statuses/firehose.json', options, &block)
end

#sample(options = {}) {|Twitter::Tweet| ... } ⇒ Object

Yields:



34
35
36
# File 'lib/twitter/streaming/client.rb', line 34

def sample(options={}, &block)
  request(:get, 'https://stream.twitter.com:443/1.1/statuses/sample.json', options, &block)
end

#site(*args) {|Twitter::Tweet| ... } ⇒ Object

Yields:



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.options.merge(:follow => arguments.join(',')), &block)
end

#user(options = {}) {|Twitter::Tweet| ... } ⇒ Object

Yields:



45
46
47
# File 'lib/twitter/streaming/client.rb', line 45

def user(options={}, &block)
  request(:get, 'https://userstream.twitter.com:443/1.1/user.json', options, &block)
end