Module: Pry::SendTweet::TwitterAction::LikeActions

Included in:
Pry::SendTweet::TwitterAction
Defined in:
lib/pry/send_tweet/commands/twitter_action/like_actions.rb

Instance Method Summary collapse

Instance Method Details

#like_tweet(tweets) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/pry/send_tweet/commands/twitter_action/like_actions.rb', line 2

def like_tweet(tweets)
  liked = twitter.favorite(tweets)
  if liked.size > 0
    render_tweets liked, title: bold("Liked tweets"), timeout: false
  else
    page_error "No tweets liked, are you sure you didn't already like those tweet(s) ..?"
  end
rescue Twitter::Error => e
  page_error(e)
end

#unlike_tweet(tweets) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/pry/send_tweet/commands/twitter_action/like_actions.rb', line 13

def unlike_tweet(tweets)
  unliked = twitter.unfavorite(tweets)
  if unliked.size > 0
    render_tweets unliked, title: bold("Unliked tweets"), timeout: false
  else
    page_error "No tweets unliked, are you sure you had liked those tweet(s) ..?"
  end
rescue Twitter::Error => e
  page_error(e)
end