Class: Twexicon::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/twexicon/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/twexicon/cli.rb', line 2

def call
  puts "Welcome to Twexicon."
  run = true

  while run
    username = Twexicon::Validator.new.run
    tweets = Twexicon::Scraper.new(username).refine_tweets
    if tweets.empty?
      puts "Unfortunately, @#{username} has never tweeted or has their tweets protected. Sorry about that."
    else
      Twexicon::Analyzer.new(username, tweets)
    end

    input = ""
    until input =~ /^[yn]$/
      puts "Would you like to look up tweets from another Twitter handle? [Y/N]"
      input = gets.strip.gsub(/\W/, "").downcase
    end
    input =~ /[n]/ ? run = false : run = true
  end

  puts "Thank you –– come again!"
end