Class: Top20Deals::CLI
- Inherits:
-
Object
- Object
- Top20Deals::CLI
- Defined in:
- lib/Top_20_Deals/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/Top_20_Deals/cli.rb', line 3 def call Top20Deals::Scraper.new.make_deals list_deals end |
#goodbye ⇒ Object
36 37 38 |
# File 'lib/Top_20_Deals/cli.rb', line 36 def goodbye puts "See you next time!" end |
#list_deals ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/Top_20_Deals/cli.rb', line 9 def list_deals puts "Hi! Here are this weeks Top 20 Travel Deals:" @deals = Top20Deals::Deals.all @deals.each.with_index(1) do |deal, i| puts "#{i}. #{deal.title} - #{deal.place} - #{deal.price}" end end |
#menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/Top_20_Deals/cli.rb', line 17 def input = nil while input != "exit" puts "Enter the number (1-20) of the deal you would like more information on. Or type 'list' to see the list again or 'exit'." input = gets.strip.downcase if input.to_i > 0 && input.to_i-1 <= 20 the_deal = Top20Deals::Deals.find(input.to_i - 1) puts "#{the_deal.title} - #{the_deal.place} - #{the_deal.price} - #{the_deal.description}" elsif input == "list" list_deals elsif input == "exit" goodbye else puts "Opps try again, invalid entry!" end end end |