Class: ApprovalRatings::CLI
- Inherits:
-
Object
- Object
- ApprovalRatings::CLI
- Defined in:
- lib/approval_ratings/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #list ⇒ Object
- #print_rating(rating) ⇒ Object
- #print_rating_i(rating) ⇒ Object
- #start ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 |
# File 'lib/approval_ratings/cli.rb', line 3 def call start end |
#list ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/approval_ratings/cli.rb', line 7 def list puts "" puts "************* President Trump Approval Ratings *************" puts "" ApprovalRatings::Rating.all.each.with_index(1) do |, i| puts "#{i}. #{.name} on #{.date}" end puts "" end |
#print_rating(rating) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/approval_ratings/cli.rb', line 17 def () .each do || puts "" puts "-------------- #{.name} --------------" puts "poll date" puts .date puts "" puts "pollster grade" puts .summary puts "" puts "approval rating" puts .approval puts "" puts "disapproval rating" puts .disapproval puts "" end end |
#print_rating_i(rating) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/approval_ratings/cli.rb', line 37 def () puts "" puts "-------------- #{.name} --------------" puts "poll date" puts .date puts "" puts "pollster grade" puts .summary puts "" puts "approval rating" puts .approval puts "" puts "disapproval rating" puts .disapproval puts "" end |
#start ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/approval_ratings/cli.rb', line 56 def start list input = nil while input != "exit" puts "" puts "What poll would you more information on, by name or number?" puts "" puts "Enter list to see the polls again." puts "Enter exit to end the program." puts "" input = gets.strip if input == "list" list elsif input.to_i == 0 if = ApprovalRatings::Rating.find_by_name(input) () end elsif input.to_i > 0 if = ApprovalRatings::Rating.find(input.to_i) () end end end puts "Goodbye!!!" end |