Class: T::Stream

Inherits:
Thor
  • Object
show all
Includes:
Printable
Defined in:
lib/t/stream.rb

Constant Summary

Constants included from Printable

Printable::MAX_SCREEN_NAME_SIZE

Instance Method Summary collapse

Methods included from Printable

#build_long_list, #build_long_status, #build_long_user, included, #print_csv_list, #print_csv_status, #print_csv_user, #print_in_columns, #print_lists, #print_status, #print_statuses, #print_users

Constructor Details

#initializeStream

Returns a new instance of Stream.



12
13
14
15
# File 'lib/t/stream.rb', line 12

def initialize(*)
  super
  @rcfile = RCFile.instance
end

Instance Method Details

#allObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/t/stream.rb', line 18

def all
  client.on_timeline_status do |status|
    print_status(status)
  end
  Signal.trap("TERM") do
    client.stop
    shutdown
  end
  client.sample
end

#matrixObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/t/stream.rb', line 30

def matrix
  client.on_timeline_status do |status|
    print("#{Thor::Shell::Color::BOLD}#{Thor::Shell::Color::GREEN}#{Thor::Shell::Color::ON_BLACK}#{status.text.gsub("\n", '')}#{Thor::Shell::Color::CLEAR}")
  end
  Signal.trap("TERM") do
    client.stop
    shutdown
  end
  client.sample
end

#search(keyword, *keywords) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/t/stream.rb', line 42

def search(keyword, *keywords)
  keywords.unshift(keyword)
  client.on_inited do
    search= T::Search.new
    search.options = search.options.merge(:reverse => true)
    search.all(keywords.join(' OR '))
  end
  client.on_timeline_status do |status|
    print_status(status)
  end
  Signal.trap("TERM") do
    client.stop
    shutdown
  end
  client.track(keywords)
end

#timelineObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/t/stream.rb', line 60

def timeline
  client.on_inited do
    cli = T::CLI.new
    cli.options = cli.options.merge(:reverse => true)
    cli.timeline
  end
  client.on_timeline_status do |status|
    print_status(status)
  end
  Signal.trap("TERM") do
    client.stop
    shutdown
  end
  client.userstream
end

#users(screen_name, *screen_names) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/t/stream.rb', line 77

def users(screen_name, *screen_names)
  screen_names.unshift(screen_name)
  client.on_timeline_status do |status|
    print_status(status)
  end
  Signal.trap("TERM") do
    client.stop
    shutdown
  end
  client.follow(screen_names)
end