Class: DelegateTracker::CLI
- Inherits:
-
Object
- Object
- DelegateTracker::CLI
- Defined in:
- lib/delegate_tracker/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #candidate_selection_list(party) ⇒ Object
- #goodbye ⇒ Object
- #parties ⇒ Object
- #party_selection ⇒ Object
- #prompt(message = "What would you like to do today?") ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 |
# File 'lib/delegate_tracker/cli.rb', line 3 def call party_selection goodbye end |
#candidate_selection_list(party) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/delegate_tracker/cli.rb', line 35 def candidate_selection_list(party) scraper = DelegateTracker::CandidateListScraper.new until [user_selection = prompt(scraper.candidates_list(party)).downcase].include?('q') if user_selection.to_i <= (scraper.count(party)) || user_selection == "r" case user_selection when "1" DelegateTracker::Candidate.create_candidate(party, 0) when "2" DelegateTracker::Candidate.create_candidate(party, 1) when "3" DelegateTracker::Candidate.create_candidate(party, 2) when "4" DelegateTracker::Candidate.create_candidate(party, 3) when "r" DelegateTracker::Candidate.create_candidate(party, (rand 0 .. scraper.count(party)-1)) end else puts "Please select from the options provided." end end party_selection end |
#goodbye ⇒ Object
57 58 59 |
# File 'lib/delegate_tracker/cli.rb', line 57 def goodbye puts "Thanks! And don't forget to VOTE!!!" end |
#parties ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/delegate_tracker/cli.rb', line 14 def parties puts "Welcome to the 2016 Presidential Candidate Delegate Tracker!" puts "" puts "Which party would you like to view?" puts "1. Democrats" puts "2. Republicans" puts "Q. Quit" end |
#party_selection ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/delegate_tracker/cli.rb', line 23 def party_selection # party_selection = prompt(parties) until [party_selection = prompt(parties).downcase].include?('q') case party_selection when "1" candidate_selection_list("democrat") when "2" candidate_selection_list("republican") end end end |
#prompt(message = "What would you like to do today?") ⇒ Object
8 9 10 11 12 |
# File 'lib/delegate_tracker/cli.rb', line 8 def prompt( = "What would you like to do today?") puts print ":> " gets.chomp end |