Class: Pry::SendTweet::ReadTweets

Inherits:
BaseCommand
  • Object
show all
Includes:
TranslateActions
Defined in:
lib/pry/send_tweet/commands/read_tweets.rb

Defined Under Namespace

Modules: TranslateActions

Constant Summary

Constants included from TranslateActions

TranslateActions::LANGUAGE_STRINGS, TranslateActions::YANDEX_ENDPOINT

Constants included from TimeAgoInWords

TimeAgoInWords::VERSION

Instance Method Summary collapse

Methods included from TranslateActions

#translate_text, #translate_tweet

Methods inherited from BaseCommand

inherited

Methods included from PagingSupport

#page, #page_error, #page_ok

Methods included from UserRenderer

#render_user

Methods included from TweetRenderer

#render_tweets

Methods included from TimeAgoInWords

time_ago_in_words

Instance Method Details

#options(o) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pry/send_tweet/commands/read_tweets.rb', line 13

def options(o)
  o.on 't=', 'tweeter=',
       'A username whose timeline you want to read.'
  o.on 'c=', 'count=',
       "The number of tweets to read. The maximum is 200, and the default is " \
       "#{default_read_size}."
  o.on 'l=', 'likes=',
       'Read tweets you or another user have liked.',
       argument: :optional
  o.on 'r=', 'replies=', 'A username whose replies you want to read.'
  o.on 'm', 'mentions', 'Read tweets that @mention you.'
  o.on 'x=', 'translate=', 'Translate a tweet.'
  o.on 'tx=', nil, 'Translate a string of text.'
  o.on 'sl=', 'source-lang=', '[optional] The source language of the ' \
                              'text or tweet being translated'
  o.on 'w', 'with-retweets', 'Include retweets.'
end

#processObject



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/pry/send_tweet/commands/read_tweets.rb', line 31

def process
  super
  case
  when opts.present?('translate') then translate_tweet(opts['x'], opts['sl'])
  when opts.present?('tx') then translate_text(opts['tx'], opts['sl'])
  when opts.present?('replies') then show_replies(user: opts['replies'])
  when opts.present?('likes') then show_likes(user: opts['likes'])
  when opts.present?('mentions') then show_mentions
  else show_tweets_from_timeline(user: opts['tweeter'])
  end
end