Sha256: 5af2e300b81022a8a88a5fee53e29ec0beedd4fd28876534bfa1d2d6c0c5d416

Contents?: true

Size: 575 Bytes

Versions: 1

Compression:

Stored size: 575 Bytes

Contents

require 'twitter'

module TWSS

  class TweetCollector

    attr_reader :search, :filename, :limit

    def initialize(search, filename, limit = 1500)
      @search, @filename, @limit = search, filename, limit
    end

    def run
      o = File.open(filename, 'a')
      page, per_page = 1, 100
      begin
        Twitter::Search.new.containing(search).per_page(per_page).page(page).each do |tweet|
          puts tweet.text
          o.puts tweet.text
        end
        page += 1
        sleep 2
      end while page * per_page < limit
      o.close
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
twss-0.0.3 lib/twss/tweet_collector.rb