Sha256: b78243b765bf0b5e610df053b9f28d7cd739867721fc7527f2463abc3411ac45

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

class LesserEvil::CommandLineInterface

	def initialize
	end

	def intro_display
		20.times { puts }

		File.open("assets/hillary.txt", "r") do |file|
			file.readlines.each do |line|
				print line.white.on_black
				sleep 0.05
			end
		end

		puts "\n\n" 
		

		File.open("assets/donald.txt", "r") do |file|
			file.readlines.each do |line|
				print line.white.on_black
				sleep 0.05
			end
		end

		puts "\n\n"
		puts "-----------------------------------".red
		puts "LESSER EVIL  ••••••••••••••••••••••".red
		puts
		puts "Peruse the angriest election tweets".red
		puts "-----------------------------------\n\n\n".red
	end
  
  def input_validation(valid_array)
  	input = gets.chomp.downcase
    while !valid_array.include?(input) do
    	print "\nInvalid input. Try again. "
    	input = gets.chomp.downcase
    end
    input
  end

	def call

    intro_display
    exit = nil

    while !exit do
	    print "Trump or Clinton? Choose a candidate: "
	    candidate = input_validation(['trump','clinton'])
	    print "Angry or very angry? "
	    very_angry = input_validation(['angry','very angry']) == 'very angry'
	    puts "\n\n"
	    tweets = LesserEvil::TweetController.new(candidate: candidate, is_intense: very_angry, sentiment: "Negative", fast_print: true).get_print_tweets
	    puts "\n\n"
	    print "New batch? (yes/no): "
	    exit = input_validation(['y','yes','n','no']).start_with?('n')
		end

	  puts "O.K.! Take it easy."

	end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lesser-evil-0.0.2 lib/lesser_evil/command_line_interface.rb
lesser-evil-0.0.1 lib/lesser_evil/command_line_interface.rb
lesser-evil-0.0.0 lib/lesser_evil/command_line_interface.rb