Class: Atig::Twitter
- Inherits:
-
BasicTwitter
- Object
- BasicTwitter
- Atig::Twitter
- Defined in:
- lib/atig/twitter.rb
Overview
from tig.rb
Instance Attribute Summary
Attributes inherited from BasicTwitter
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context, oauth) ⇒ Twitter
constructor
A new instance of Twitter.
- #page(path, name, opts = {}, &block) ⇒ Object
Methods inherited from BasicTwitter
Constructor Details
#initialize(context, oauth) ⇒ Twitter
Returns a new instance of Twitter.
10 11 12 13 14 |
# File 'lib/atig/twitter.rb', line 10 def initialize(context, oauth) super context, :api_base @oauth = oauth @http = Atig::Http.new @log end |
Class Method Details
.http_methods(*methods) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/atig/twitter.rb', line 30 def self.http_methods(*methods) methods.each do |m| self.module_eval " def \#{m}(path, query = {}, opts = {})\n opts.update( method: :\#{m})\n api path, query, opts\n end\n" end end |
Instance Method Details
#page(path, name, opts = {}, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/atig/twitter.rb', line 16 def page(path, name, opts = {}, &block) limit = 0.98 * @remain # 98% of IP based rate limit r = [] cursor = -1 1.upto(limit) do |num| = {cursor: cursor}.merge(opts) ret = api(path, , { authenticate: true }) r.concat ret[name] cursor = ret[:next_cursor] break if cursor.zero? end r end |