Class: Atig::Twitter

Inherits:
BasicTwitter show all
Defined in:
lib/atig/twitter.rb

Overview

from tig.rb

Instance Attribute Summary

Attributes inherited from BasicTwitter

#limit, #remain, #reset

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BasicTwitter

#api

Constructor Details

#initialize(context, oauth) ⇒ Twitter

Returns a new instance of Twitter.



9
10
11
12
13
# File 'lib/atig/twitter.rb', line 9

def initialize(context, oauth)
  super context, :api_base
  @oauth = oauth
  @http  = Atig::Http.new @log
end

Class Method Details

.http_methods(*methods) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/atig/twitter.rb', line 29

def self.http_methods(*methods)
  methods.each do |m|
    self.module_eval <<END
      def #{m}(path, query = {}, opts = {})
        opts.update( :method => :#{m})
        api path, query, opts
      end
END
  end
end

Instance Method Details

#page(path, name, opts = {}, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/atig/twitter.rb', line 15

def page(path, name, opts = {}, &block)
  limit = 0.98 * @remain # 98% of IP based rate limit
  r     = []
  cursor = -1
  1.upto(limit) do |num|
    options = {:cursor => cursor}.merge(opts)
    ret = api(path, options, { :authenticate => true })
    r.concat ret[name]
    cursor = ret[:next_cursor]
    break if cursor.zero?
  end
  r
end