Module: Twitter::Client::Lists
- Included in:
- Twitter::Client
- Defined in:
- lib/twitter/client/lists.rb
Instance Method Summary collapse
-
#list(*args) ⇒ Object
Show the specified list.
-
#list_add_member(*args) ⇒ Object
Add a member to a list.
-
#list_add_members(*args) ⇒ Object
Adds multiple members to a list.
-
#list_create(name, options = {}) ⇒ Twitter::List
Creates a new list for the authenticated user.
-
#list_destroy(*args) ⇒ Object
Deletes the specified list.
-
#list_member?(*args) ⇒ Object
Check if a user is a member of the specified list.
-
#list_members(*args) ⇒ Object
Returns the members of the specified list.
-
#list_remove_member(*args) ⇒ Object
Removes the specified member from the list.
-
#list_subscribe(*args) ⇒ Object
Make the authenticated user follow the specified list.
-
#list_subscriber?(*args) ⇒ Boolean
Check if a user is a subscriber of the specified list.
-
#list_subscribers(*args) ⇒ Object
Returns the subscribers of the specified list.
-
#list_timeline(*args) ⇒ Object
Show tweet timeline for members of the specified list.
-
#list_unsubscribe(*args) ⇒ Object
Unsubscribes the authenticated user form the specified list.
-
#list_update(*args) ⇒ Object
Updates the specified list.
-
#lists(*args) ⇒ Object
List the lists of the specified user.
-
#lists_subscribed_to(*args) ⇒ Object
Returns all lists the authenticating or specified user subscribes to, including their own.
-
#memberships(*args) ⇒ Object
List the lists the specified user has been added to.
-
#subscriptions(*args) ⇒ Object
List the lists the specified user follows.
Instance Method Details
#list(list, options = {}) ⇒ Twitter::List #list(user, list, options = {}) ⇒ Twitter::List
Private lists will only be shown if the authenticated user owns the specified list.
Show the specified list
631 632 633 634 635 636 637 638 639 |
# File 'lib/twitter/client/lists.rb', line 631 def list(*args) = args.last.is_a?(Hash) ? args.pop : {} list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = get("/1/lists/show.json", ) Twitter::List.new(list) end |
#list_add_member(list, user_to_add, options = {}) ⇒ Twitter::List #list_add_member(user, list, user_to_add, options = {}) ⇒ Twitter::List
Lists are limited to having 500 members.
Add a member to a list
472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/twitter/client/lists.rb', line 472 def list_add_member(*args) = args.last.is_a?(Hash) ? args.pop : {} user_to_add = args.pop .merge_user!(user_to_add) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = post("/1/lists/members/create.json", ) Twitter::List.new(list) end |
#list_add_members(list, users_to_add, options = {}) ⇒ Twitter::List #list_add_members(user, list, users_to_add, options = {}) ⇒ Twitter::List
Lists are limited to having 500 members, and you are limited to adding up to 100 members to a list at a time with this method.
Adds multiple members to a list
356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/twitter/client/lists.rb', line 356 def list_add_members(*args) = args.last.is_a?(Hash) ? args.pop : {} users_to_add = args.pop .merge_users!(Array(users_to_add)) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = post("/1/lists/members/create_all.json", ) Twitter::List.new(list) end |
#list_create(name, options = {}) ⇒ Twitter::List
Accounts are limited to 20 lists.
Creates a new list for the authenticated user
571 572 573 574 |
# File 'lib/twitter/client/lists.rb', line 571 def list_create(name, ={}) list = post("/1/lists/create.json", .merge(:name => name)) Twitter::List.new(list) end |
#list_destroy(list, options = {}) ⇒ Twitter::List #list_destroy(user, list, options = {}) ⇒ Twitter::List
Must be owned by the authenticated user.
Deletes the specified list
509 510 511 512 513 514 515 516 517 |
# File 'lib/twitter/client/lists.rb', line 509 def list_destroy(*args) = args.last.is_a?(Hash) ? args.pop : {} list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = delete("/1/lists/destroy.json", ) Twitter::List.new(list) end |
#list_member?(list, user_to_check, options = {}) ⇒ Boolean #list_member?(user, list, user_to_check, options = {}) ⇒ Boolean
Check if a user is a member of the specified list
393 394 395 396 397 398 399 400 401 402 403 404 405 |
# File 'lib/twitter/client/lists.rb', line 393 def list_member?(*args) = args.last.is_a?(Hash) ? args.pop : {} user_to_check = args.pop .merge_user!(user_to_check) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) get("/1/lists/members/show.json", , :raw => true) true rescue Twitter::Error::NotFound, Twitter::Error::Forbidden false end |
#list_members(list, options = {}) ⇒ Twitter::Cursor #list_members(user, list, options = {}) ⇒ Twitter::Cursor
Returns the members of the specified list
435 436 437 438 439 440 441 442 443 |
# File 'lib/twitter/client/lists.rb', line 435 def list_members(*args) = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {}) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) cursor = get("/1/lists/members.json", ) Twitter::Cursor.new(cursor, 'users', Twitter::User) end |
#list_remove_member(list, user_to_remove, options = {}) ⇒ Twitter::List #list_remove_member(user, list, user_to_remove, options = {}) ⇒ Twitter::List
Removes the specified member from the list
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/twitter/client/lists.rb', line 110 def list_remove_member(*args) = args.last.is_a?(Hash) ? args.pop : {} user_to_remove = args.pop .merge_user!(user_to_remove) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = post("/1/lists/members/destroy.json", ) Twitter::List.new(list) end |
#list_subscribe(list, options = {}) ⇒ Twitter::List #list_subscribe(user, list, options = {}) ⇒ Twitter::List
Make the authenticated user follow the specified list
242 243 244 245 246 247 248 249 250 |
# File 'lib/twitter/client/lists.rb', line 242 def list_subscribe(*args) = args.last.is_a?(Hash) ? args.pop : {} list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = post("/1/lists/subscribers/create.json", ) Twitter::List.new(list) end |
#list_subscriber?(list, user_to_check, options = {}) ⇒ Boolean #list_subscriber?(user, list, user_to_check, options = {}) ⇒ Boolean
Check if a user is a subscriber of the specified list
280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/twitter/client/lists.rb', line 280 def list_subscriber?(*args) = args.last.is_a?(Hash) ? args.pop : {} user_to_check = args.pop .merge_user!(user_to_check) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) get("/1/lists/subscribers/show.json", , :raw => true) true rescue Twitter::Error::NotFound, Twitter::Error::Forbidden false end |
#list_subscribers(list, options = {}) ⇒ Twitter::Cursor #list_subscribers(user, list, options = {}) ⇒ Twitter::Cursor
Returns the subscribers of the specified list
179 180 181 182 183 184 185 186 187 |
# File 'lib/twitter/client/lists.rb', line 179 def list_subscribers(*args) = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {}) list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) cursor = get("/1/lists/subscribers.json", ) Twitter::Cursor.new(cursor, 'users', Twitter::User) end |
#list_timeline(list, options = {}) ⇒ Array<Twitter::Status> #list_timeline(user, list, options = {}) ⇒ Array<Twitter::Status>
Show tweet timeline for members of the specified list
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/twitter/client/lists.rb', line 72 def list_timeline(*args) = args.last.is_a?(Hash) ? args.pop : {} list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) get("/1/lists/statuses.json", ).map do |status| Twitter::Status.new(status) end end |
#list_unsubscribe(list, options = {}) ⇒ Twitter::List #list_unsubscribe(user, list, options = {}) ⇒ Twitter::List
Unsubscribes the authenticated user form the specified list
317 318 319 320 321 322 323 324 325 |
# File 'lib/twitter/client/lists.rb', line 317 def list_unsubscribe(*args) = args.last.is_a?(Hash) ? args.pop : {} list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = post("/1/lists/subscribers/destroy.json", ) Twitter::List.new(list) end |
#list_update(list, options = {}) ⇒ Twitter::List #list_update(user, list, options = {}) ⇒ Twitter::List
Updates the specified list
547 548 549 550 551 552 553 554 555 |
# File 'lib/twitter/client/lists.rb', line 547 def list_update(*args) = args.last.is_a?(Hash) ? args.pop : {} list = args.pop .merge_list!(list) owner = args.pop || self.current_user.screen_name .merge_owner!(owner) list = post("/1/lists/update.json", ) Twitter::List.new(list) end |
#lists(options = {}) ⇒ Twitter::Cursor #lists(user, options = {}) ⇒ Twitter::Cursor
Private lists will be included if the authenticated user is the same as the user whose lists are being returned.
List the lists of the specified user
598 599 600 601 602 603 604 |
# File 'lib/twitter/client/lists.rb', line 598 def lists(*args) = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {}) user = args.first .merge_user!(user) if user cursor = get("/1/lists.json", ) Twitter::Cursor.new(cursor, 'lists', Twitter::List) end |
#lists_subscribed_to(options = {}) ⇒ Array<Twitter::Status> #lists_subscribed_to(user, options = {}) ⇒ Array<Twitter::List>
Returns all lists the authenticating or specified user subscribes to, including their own
30 31 32 33 34 35 36 37 38 |
# File 'lib/twitter/client/lists.rb', line 30 def lists_subscribed_to(*args) = args.last.is_a?(Hash) ? args.pop : {} if user = args.pop .merge_user!(user) end get("/1/lists/all.json", ).map do |list| Twitter::List.new(list) end end |
#memberships(options = {}) ⇒ Twitter::Cursor #memberships(user, options = {}) ⇒ Twitter::Cursor
List the lists the specified user has been added to
143 144 145 146 147 148 149 150 |
# File 'lib/twitter/client/lists.rb', line 143 def memberships(*args) = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {}) if user = args.pop .merge_user!(user) end cursor = get("/1/lists/memberships.json", ) Twitter::Cursor.new(cursor, 'lists', Twitter::List) end |
#subscriptions(options = {}) ⇒ Twitter::Cursor #subscriptions(user, options = {}) ⇒ Twitter::Cursor
List the lists the specified user follows
210 211 212 213 214 215 216 217 |
# File 'lib/twitter/client/lists.rb', line 210 def subscriptions(*args) = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {}) if user = args.pop .merge_user!(user) end cursor = get("/1/lists/subscriptions.json", ) Twitter::Cursor.new(cursor, 'lists', Twitter::List) end |