class Twitter2Jabber
Constants
- VERSION
Attributes
debug[R]
jabber[R]
twitter[R]
Public Class Methods
client(client)
click to toggle source
# File lib/twitter2jabber.rb 35 def client(client) 36 const_get("#{client.to_s.capitalize}Client") 37 end
new(options)
click to toggle source
# File lib/twitter2jabber.rb 41 def initialize(options) 42 @twitter = initialize_client(:twitter, options) 43 @jabber = initialize_client(:jabber, options) 44 45 if @debug = options[:debug] or options[:verbose] 46 @spec = "#{twitter.spec} -> #{jabber.spec}" 47 48 @log = options[:log] || $stderr 49 @log.sync = true 50 51 require 'time' 52 else 53 define_singleton_method(:log) { |_| } 54 end 55 end
run(options, since_id = nil)
click to toggle source
# File lib/twitter2jabber.rb 31 def run(options, since_id = nil) 32 new(options).connect.deliver_tweets(since_id).disconnect 33 end
Public Instance Methods
connect()
click to toggle source
# File lib/twitter2jabber.rb 59 def connect 60 log 'Connecting...' 61 62 twitter.connect 63 jabber.connect 64 65 self 66 end
deliver_tweets(since_id = nil)
click to toggle source
# File lib/twitter2jabber.rb 77 def deliver_tweets(since_id = nil) 78 twitter.tweets(since_id) { |tweet| jabber.deliver(tweet) } 79 self 80 end
disconnect()
click to toggle source
# File lib/twitter2jabber.rb 68 def disconnect 69 log 'Disconnecting...' 70 71 twitter.disconnect 72 jabber.disconnect 73 74 self 75 end
log(msg)
click to toggle source
# File lib/twitter2jabber.rb 82 def log(msg) 83 @log.puts "#{Time.now.xmlschema} [#{@spec}] #{msg}" 84 end
Private Instance Methods
initialize_client(client, options)
click to toggle source
# File lib/twitter2jabber.rb 88 def initialize_client(client, options) 89 (config = options[client]).is_a?(Hash) ? 90 self.class.client(client).new(self, config) : 91 raise(ArgumentError, "#{client} config missing") 92 end