Method: T::Stream#all

Defined in:
lib/t/stream.rb

#allObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/t/stream.rb', line 31

def all
  streaming_client.before_request do
    if options["csv"]
      require "csv"
      say TWEET_HEADINGS.to_csv
    elsif options["long"] && STDOUT.tty?
      headings = Array.new(TWEET_HEADINGS.size) do |index|
        TWEET_HEADINGS_FORMATTING[index] % TWEET_HEADINGS[index]
      end
      print_table([headings])
    end
  end
  streaming_client.sample do |tweet|
    next unless tweet.is_a?(Twitter::Tweet)

    if options["csv"]
      print_csv_tweet(tweet)
    elsif options["long"]
      array = build_long_tweet(tweet).each_with_index.collect do |element, index|
        TWEET_HEADINGS_FORMATTING[index] % element
      end
      print_table([array], truncate: STDOUT.tty?)
    else
      print_message(tweet.user.screen_name, tweet.text)
    end
  end
end