Class: BirdGrinder::Tweeter::Streaming

Inherits:
Object
  • Object
show all
Defined in:
lib/bird_grinder/tweeter/streaming.rb

Overview

Basic support for the twitter streaming api. Provides access to sample, filter, follow and track. Note that it will dispatch messages as :incoming_stream, with options.streaming_source set to the stream origin.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Streaming

Initializes a streaming subclient for a given tweeter

Parameters:



21
22
23
24
# File 'lib/bird_grinder/tweeter/streaming.rb', line 21

def initialize(parent)
  @parent = parent
  logger.debug "Initializing Streaming Support"
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



16
17
18
# File 'lib/bird_grinder/tweeter/streaming.rb', line 16

def parent
  @parent
end

Instance Method Details

#filter(opts = {}) ⇒ Object

Start processing the filter stream

Parameters:

  • opts (Hash) (defaults to: {})

    extra options for the query



36
37
38
# File 'lib/bird_grinder/tweeter/streaming.rb', line 36

def filter(opts = {})
  stream(:filter, opts)
end

#follow(*args) ⇒ Object

Start processing the filter stream with a given follow argument.

Parameters:

  • args (Array)

    what to follow, joined with “,” followed by opts



44
45
46
47
48
49
# File 'lib/bird_grinder/tweeter/streaming.rb', line 44

def follow(*args)
  opts = args.extract_options!
  opts[:follow] = args.flatten.join(",")
  opts[:path] = :filter
  stream(:follow, opts)
end

#sample(opts = {}) ⇒ Object

Start processing the sample stream

Parameters:

  • opts (Hash) (defaults to: {})

    extra options for the query



29
30
31
# File 'lib/bird_grinder/tweeter/streaming.rb', line 29

def sample(opts = {})
  stream(:sample, opts)
end

#track(*args) ⇒ Object

Starts tracking a specific query.

Parameters:

  • args (Array)

    what to track, joined with “,” followed by opts



54
55
56
57
58
59
# File 'lib/bird_grinder/tweeter/streaming.rb', line 54

def track(*args)
  opts = args.extract_options!
  opts[:track] = args.flatten.join(",")
  opts[:path] = :filter
  stream(:track, opts)
end