Class: T::Stream
Constant Summary
collapse
[
'%-18s', '%-12s', '%-20s', '%s', ]
Constants included
from Printable
Printable::LIST_HEADINGS, Printable::MONTH_IN_SECONDS, Printable::TWEET_HEADINGS, Printable::USER_HEADINGS
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Stream
Returns a new instance of Stream.
19
20
21
22
|
# File 'lib/t/stream.rb', line 19
def initialize(*)
@rcfile = T::RCFile.instance
super
end
|
Instance Method Details
#all ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/t/stream.rb', line 27
def all
client.before_request do
if options['csv']
require 'csv'
say TWEET_HEADINGS.to_csv
elsif options['long'] && STDOUT.tty?
headings = TWEET_HEADINGS.size.times.map do |index|
TWEET_HEADINGS_FORMATTING[index] % TWEET_HEADINGS[index]
end
print_table([headings])
end
end
client.sample do ||
next unless .is_a?(Twitter::Tweet)
if options['csv']
()
elsif options['long']
array = ().each_with_index.map do |element, index|
TWEET_HEADINGS_FORMATTING[index] % element
end
print_table([array], :truncate => STDOUT.tty?)
else
print_message(.user.screen_name, .text)
end
end
end
|
#matrix ⇒ Object
55
56
57
58
59
60
|
# File 'lib/t/stream.rb', line 55
def matrix
client.sample(:language => 'ja') do ||
next unless .is_a?(Twitter::Tweet)
say(.full_text.gsub("\n", '').reverse, [:bold, :green, :on_black])
end
end
|
#search(keyword, *keywords) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/t/stream.rb', line 65
def search(keyword, *keywords)
keywords.unshift(keyword)
require 't/search'
client.before_request do
search = T::Search.new
search.options = search.options.merge(options)
search.options = search.options.merge(:reverse => true)
search.options = search.options.merge(:format => TWEET_HEADINGS_FORMATTING)
search.all(keywords.join(' OR '))
end
client.filter(:track => keywords) do ||
next unless .is_a?(Twitter::Tweet)
if options['csv']
()
elsif options['long']
array = ().each_with_index.map do |element, index|
TWEET_HEADINGS_FORMATTING[index] % element
end
print_table([array], :truncate => STDOUT.tty?)
else
print_message(.user.screen_name, .text)
end
end
end
|
#timeline ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/t/stream.rb', line 93
def timeline
require 't/cli'
client.before_request do
cli = T::CLI.new
cli.options = cli.options.merge(options)
cli.options = cli.options.merge(:reverse => true)
cli.options = cli.options.merge(:format => TWEET_HEADINGS_FORMATTING)
cli.timeline
end
client.user do ||
next unless .is_a?(Twitter::Tweet)
if options['csv']
()
elsif options['long']
array = ().each_with_index.map do |element, index|
TWEET_HEADINGS_FORMATTING[index] % element
end
print_table([array], :truncate => STDOUT.tty?)
else
print_message(.user.screen_name, .text)
end
end
end
|
#users(user_id, *user_ids) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/t/stream.rb', line 120
def users(user_id, *user_ids)
user_ids.unshift(user_id)
user_ids.map!(&:to_i)
client.before_request do
if options['csv']
require 'csv'
say TWEET_HEADINGS.to_csv
elsif options['long'] && STDOUT.tty?
headings = TWEET_HEADINGS.size.times.map do |index|
TWEET_HEADINGS_FORMATTING[index] % TWEET_HEADINGS[index]
end
print_table([headings])
end
end
client.follow(user_ids) do ||
next unless .is_a?(Twitter::Tweet)
if options['csv']
()
elsif options['long']
array = ().each_with_index.map do |element, index|
TWEET_HEADINGS_FORMATTING[index] % element
end
print_table([array], :truncate => STDOUT.tty?)
else
print_message(.user.screen_name, .text)
end
end
end
|