Sha256: daf405343bc27098959965b1241017aec2835ccda36455c5e40a91e402c4f951

Contents?: true

Size: 584 Bytes

Versions: 8

Compression:

Stored size: 584 Bytes

Contents

require "supermodel"

class Tweet < SuperModel::Base
  class << self
    def poll
      destroy_all
      populate(timeline)
    end
    
    def timeline
      twitter.friends_timeline.collect {|t|
        t.delete('user')
        t.to_hash
      }
    end
    
    def update(status)
      twitter.update(status)
    end

    private
      def twitter
        httpauth = Twitter::HTTPAuth.new(
          AppConfig.username, 
          AppConfig.password
        )
        Twitter::Base.new(httpauth)
      end
  end
end

Thread.new do
  loop do
    Tweet.poll
    sleep 60
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bowline-0.9.4 examples/tweet.rb
bowline-0.9.3 examples/tweet.rb
bowline-0.9.2 examples/tweet.rb
bowline-0.9.1 examples/tweet.rb
bowline-0.6.3 examples/tweet.rb
bowline-0.6.2 examples/tweet.rb
bowline-0.6.1 examples/tweet.rb
bowline-0.6.0 examples/tweet.rb