Class: Twitter4j4r::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter4j4r/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth_map) ⇒ Client

Returns a new instance of Client.



9
10
11
# File 'lib/twitter4j4r/client.rb', line 9

def initialize(auth_map)
  @stream = Java::Twitter4j::TwitterStreamFactory.new(config(auth_map)).instance
end

Instance Method Details

#on_exception(&block) ⇒ Object



13
14
15
16
# File 'lib/twitter4j4r/client.rb', line 13

def on_exception(&block)
  @exception_block = block
  self
end

#on_limitation(&block) ⇒ Object



18
19
20
21
# File 'lib/twitter4j4r/client.rb', line 18

def on_limitation(&block)
  @limitation_block = block
  self
end

#on_status(&block) ⇒ Object



23
24
25
26
# File 'lib/twitter4j4r/client.rb', line 23

def on_status(&block)
  @status_block = block
  self
end

#start(search_terms) ⇒ Object



33
34
35
36
# File 'lib/twitter4j4r/client.rb', line 33

def start(search_terms)
  @stream.addListener(Listener.new(self, @status_block, @exception_block, @limitation_block))
  @stream.filter(Java::Twitter4j::FilterQuery.new(0, nil, search_terms.to_java(:string)))
end

#stopObject



38
39
40
41
# File 'lib/twitter4j4r/client.rb', line 38

def stop
  @stream.cleanUp
  @stream.shutdown
end

#track(*terms, &block) ⇒ Object



28
29
30
31
# File 'lib/twitter4j4r/client.rb', line 28

def track(*terms, &block)
  on_status(&block)
  start(terms)
end