Module: Twitter::Client::Users
- Included in:
- Twitter::Client
- Defined in:
- lib/twitter/client/users.rb
Overview
Defines methods related to users
Instance Method Summary collapse
-
#contributees(*args) ⇒ Object
Returns an array of users that the specified user can contribute to.
-
#contributors(*args) ⇒ Object
Returns an array of users who can contribute to the specified account.
-
#profile_image(screen_name, options = {}) ⇒ String
Access the profile image in various sizes for the user with the indicated screen name.
-
#recommendations(options = {}) ⇒ Array<Twitter::User>
Returns recommended users for the authenticated user.
-
#user(user, options = {}) ⇒ Twitter::User
Returns extended information of a given user.
-
#user?(user, options = {}) ⇒ Boolean
Returns true if the specified user exists.
-
#user_search(query, options = {}) ⇒ Array<Twitter::User>
Returns users that match the given query.
-
#users(*users, options = {}) ⇒ Array<Twitter::User>
Returns extended information for up to 100 users.
Instance Method Details
#contributees(options = {}) ⇒ Array<Twitter::User> #contributees(user, options = {}) ⇒ Array<Twitter::User>
Returns an array of users that the specified user can contribute to
137 138 139 140 141 142 143 144 145 |
# File 'lib/twitter/client/users.rb', line 137 def contributees(*args) = {} .merge!(args.last.is_a?(Hash) ? args.pop : {}) user = args.pop || self.current_user.screen_name .merge_user!(user) get("/1/users/contributees.json", ).map do |user| Twitter::User.new(user) end end |
#contributors(options = {}) ⇒ Array<Twitter::User> #contributors(user, options = {}) ⇒ Array<Twitter::User>
Returns an array of users who can contribute to the specified account
170 171 172 173 174 175 176 177 178 |
# File 'lib/twitter/client/users.rb', line 170 def contributors(*args) = {} .merge!(args.last.is_a?(Hash) ? args.pop : {}) user = args.pop || self.current_user.screen_name .merge_user!(user) get("/1/users/contributors.json", ).map do |user| Twitter::User.new(user) end end |
#profile_image(screen_name, options = {}) ⇒ String
Access the profile image in various sizes for the user with the indicated screen name
47 48 49 50 51 |
# File 'lib/twitter/client/users.rb', line 47 def profile_image(*args) = args.last.is_a?(Hash) ? args.pop : {} screen_name = args.pop || self.current_user.screen_name get("/1/users/profile_image/#{screen_name}", , :raw => true).headers['location'] end |
#recommendations(options = {}) ⇒ Array<Twitter::User>
Returns recommended users for the authenticated user
194 195 196 197 198 199 |
# File 'lib/twitter/client/users.rb', line 194 def recommendations(={}) [:excluded] = [:excluded].join(',') if [:excluded].is_a?(Array) get("/1/users/recommendations.json", ).map do |recommendation| Twitter::User.new(recommendation['user']) end end |
#user(user, options = {}) ⇒ Twitter::User
Returns extended information of a given user
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/twitter/client/users.rb', line 86 def user(*args) = args.last.is_a?(Hash) ? args.pop : {} if user = args.pop .merge_user!(user) user = get("/1/users/show.json", ) else user = get("/1/account/verify_credentials.json", ) end Twitter::User.new(user) end |
#user?(user, options = {}) ⇒ Boolean
Returns true if the specified user exists
106 107 108 109 110 111 112 |
# File 'lib/twitter/client/users.rb', line 106 def user?(user, ={}) .merge_user!(user) get("/1/users/show.json", , :raw => true) true rescue Twitter::Error::NotFound false end |
#user_search(query, options = {}) ⇒ Array<Twitter::User>
Returns users that match the given query
67 68 69 70 71 |
# File 'lib/twitter/client/users.rb', line 67 def user_search(query, ={}) get("/1/users/search.json", .merge(:q => query)).map do |user| Twitter::User.new(user) end end |
#users(*users, options = {}) ⇒ Array<Twitter::User>
Returns extended information for up to 100 users
26 27 28 29 30 31 32 33 |
# File 'lib/twitter/client/users.rb', line 26 def users(*args) = args.last.is_a?(Hash) ? args.pop : {} users = args .merge_users!(Array(users)) get("/1/users/lookup.json", ).map do |user| Twitter::User.new(user) end end |