Included Modules

Files

Twitter

Constants

API_VERSION

Public Class Methods

api_endpoint() click to toggle source
    # File lib/twitter.rb, line 29
29:   def self.api_endpoint
30:     @api_endpoint ||= "api.twitter.com/#{API_VERSION}"
31:   end
api_endpoint=(value) click to toggle source
    # File lib/twitter.rb, line 33
33:   def self.api_endpoint=(value)
34:     @api_endpoint = value
35:   end
firehose(options = {}) click to toggle source
    # File lib/twitter.rb, line 37
37:   def self.firehose(options = {})
38:     perform_get("/statuses/public_timeline.json")
39:   end
follower_ids(id,options={}) click to toggle source
    # File lib/twitter.rb, line 53
53:   def self.follower_ids(id,options={})
54:     perform_get("/followers/ids/#{id}.json")
55:   end
friend_ids(id,options={}) click to toggle source
    # File lib/twitter.rb, line 49
49:   def self.friend_ids(id,options={})    
50:     perform_get("/friends/ids/#{id}.json")
51:   end
list_timeline(list_owner_username, slug, query = {}) click to toggle source

:per_page = max number of statues to get at once :page = which page of tweets you wish to get

    # File lib/twitter.rb, line 63
63:   def self.list_timeline(list_owner_username, slug, query = {})
64:     perform_get("/#{list_owner_username}/lists/#{slug}/statuses.json", :query => query)
65:   end
status(id,options={}) click to toggle source
    # File lib/twitter.rb, line 45
45:   def self.status(id,options={})
46:     perform_get("/statuses/show/#{id}.json")
47:   end
timeline(id, options={}) click to toggle source
    # File lib/twitter.rb, line 57
57:   def self.timeline(id, options={})
58:     perform_get("/statuses/user_timeline/#{id}.json", :query => options)
59:   end
user(id,options={}) click to toggle source
    # File lib/twitter.rb, line 41
41:   def self.user(id,options={})
42:     perform_get("/users/show/#{id}.json")
43:   end

Private Class Methods

make_friendly(response) click to toggle source
    # File lib/twitter.rb, line 74
74:   def self.make_friendly(response)
75:     raise_errors(response)
76:     data = parse(response)
77:     # Don't mash arrays of integers
78:     if data && data.is_a?(Array) && data.first.is_a?(Integer)
79:       data
80:     else
81:       mash(data)
82:     end
83:   end
make_mash_with_consistent_hash(obj) click to toggle source

Lame workaround for the fact that mash doesn’t hash correctly

     # File lib/twitter.rb, line 120
120:   def self.make_mash_with_consistent_hash(obj)
121:     m = Hashie::Mash.new(obj)
122:     def m.hash
123:       inspect.hash
124:     end
125:     return m
126:   end
mash(obj) click to toggle source
     # File lib/twitter.rb, line 109
109:   def self.mash(obj)
110:     if obj.is_a?(Array)
111:       obj.map{|item| make_mash_with_consistent_hash(item)}
112:     elsif obj.is_a?(Hash)
113:       make_mash_with_consistent_hash(obj)
114:     else
115:       obj
116:     end
117:   end
parse(response) click to toggle source
     # File lib/twitter.rb, line 105
105:   def self.parse(response)
106:     Yajl::Parser.parse(response.body)
107:   end
perform_get(uri, options = {}) click to toggle source
    # File lib/twitter.rb, line 69
69:   def self.perform_get(uri, options = {})
70:     base_uri self.api_endpoint
71:     make_friendly(get(uri, options))
72:   end
raise_errors(response) click to toggle source
     # File lib/twitter.rb, line 85
 85:   def self.raise_errors(response)
 86:     case response.code.to_i
 87:       when 400
 88:         data = parse(response)
 89:         raise RateLimitExceeded.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}"
 90:       when 401
 91:         data = parse(response)
 92:         raise Unauthorized.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}"
 93:       when 403
 94:         data = parse(response)
 95:         raise General.new(data), "(#{response.code}): #{response.message} - #{data['error'] if data}"
 96:       when 404
 97:         raise NotFound, "(#{response.code}): #{response.message}"
 98:       when 500
 99:         raise InformTwitter, "Twitter had an internal error. Please let them know in the group. (#{response.code}): #{response.message}"
100:       when 502..503
101:         raise Unavailable, "(#{response.code}): #{response.message}"
102:     end
103:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.