Class: Twitter4j4r::Client
- Inherits:
-
Object
- Object
- Twitter4j4r::Client
- Defined in:
- lib/twitter4j4r/client.rb
Instance Method Summary collapse
-
#initialize(auth_map) ⇒ Client
constructor
A new instance of Client.
- #on_exception(&block) ⇒ Object
- #on_limitation(&block) ⇒ Object
- #on_status(&block) ⇒ Object
- #start(search_terms) ⇒ Object
- #stop ⇒ Object
- #track(*terms, &block) ⇒ Object
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 |
#stop ⇒ Object
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 |