module Pry::SendTweet::TwitterAction::FollowActions
Public Instance Methods
follow_user(users)
click to toggle source
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 2 def follow_user(users) users = search_str_for_users(*users) follows = twitter.follow(users) if follows.size > 0 page_ok "followed #{join_usernames(follows.map(&:screen_name))}." else page_error "are you already following #{join_usernames(users)} ..?" end rescue Twitter::Error => e page_error(e) end
show_followers(pattern)
click to toggle source
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 26 def show_followers(pattern) followers = Array twitter.followers(follow_request_options) __follow_filter!(followers, pattern) if pattern page numbered_list("Followers", followers) {|follower, index| render_user(follower) } rescue Twitter::Error => e page_error(e) end
show_following(pattern)
click to toggle source
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 36 def show_following(pattern) followings = Array twitter.following(follow_request_options) __follow_filter!(followings, pattern) if pattern page numbered_list("Following", followings) {|following, index| render_user(following) } rescue Twitter::Error => e page_error(e) end
unfollow_user(users)
click to toggle source
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 14 def unfollow_user(users) users = search_str_for_users(*users) unfollows = twitter.unfollow(users) if unfollows.size > 0 page_ok "unfollowed #{join_usernames(unfollows.map(&:screen_name))}." else page_error "did you already unfollow #{join_usernames(users)} ..?" end rescue Twitter::Error => e page_error(e) end
Private Instance Methods
__follow_filter!(users, pattern)
click to toggle source
@api private
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 49 def __follow_filter!(users, pattern) users.select! do |u| u.screen_name =~ /#{pattern}/ end end
follow_request_options()
click to toggle source
@api private
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 56 def follow_request_options {skip_status: true, include_user_entities: true} end
join_usernames(users)
click to toggle source
@api private
# File lib/pry/send_tweet/commands/twitter_action/follow_actions.rb, line 61 def join_usernames(users) users.map do |username| bold("@#{username}") + " ( https://twitter.com/#{username} )" end.join(', ') end