Class: TweetStream::Daemon

Inherits:
Client
  • Object
show all
Defined in:
lib/tweetstream/daemon.rb

Overview

A daemonized TweetStream client that will allow you to create backgroundable scripts for application specific processes. For instance, if you create a script called tracker.rb and fill it with this:

require 'rubygems'
require 'tweetstream'

TweetStream::Daemon.new('user','pass', 'tracker').track('intridea') do |status|
  # do something here
end

And then you call this from the shell:

ruby tracker.rb start

A daemon process will spawn that will automatically run the code in the passed block whenever a new tweet matching your search term (‘intridea’ in this case) is posted.

Instance Attribute Summary

Attributes inherited from Client

#password, #username

Instance Method Summary collapse

Methods inherited from Client

#filter, #firehose, #follow, #on_delete, #on_limit, #retweet, #sample, #track

Constructor Details

#initialize(user, pass, app_name = nil) ⇒ Daemon

Initialize a Daemon with the credentials of the Twitter account you wish to use. The daemon has an optional process name for use when querying running processes.



29
30
31
32
# File 'lib/tweetstream/daemon.rb', line 29

def initialize(user, pass, app_name=nil)
  @app_name = app_name
  super(user, pass)
end

Instance Method Details

#start(path, query_parameters = {}, &block) ⇒ Object

:nodoc:



34
35
36
37
38
# File 'lib/tweetstream/daemon.rb', line 34

def start(path, query_parameters = {}, &block) #:nodoc:
  Daemons.run_proc(@app_name || 'tweetstream', :multiple => true) do
    super(path, query_parameters, &block)
  end
end