Class: NYCTheaterDiscounts::CLI
- Inherits:
-
Object
- Object
- NYCTheaterDiscounts::CLI
- Defined in:
- lib/nyc_theater_discounts/cli.rb
Instance Method Summary collapse
- #by_show_menu ⇒ Object
- #by_vendor_menu ⇒ Object
- #call ⇒ Object
- #goodbye ⇒ Object
- #list_deals(vendor) ⇒ Object
- #list_vendors ⇒ Object
- #menu(input) ⇒ Object
- #starting_menu ⇒ Object
Instance Method Details
#by_show_menu ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/nyc_theater_discounts/cli.rb', line 68 def puts "Please enter the title of the show you would like to check:" input = gets.strip input.to_s NYCTheaterDiscounts::Vendor.all.each do |vendor| vendor.shows.each do |show| if show.name.downcase.include? input.downcase puts "At #{vendor.name}: #{show.name} -- available from: #{show.price}" puts "**to see this offer visit: #{show.deal_url}**\n\n" end end end puts "We did not find any additional shows associated with your query." end |
#by_vendor_menu ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/nyc_theater_discounts/cli.rb', line 60 def list_vendors puts "Please enter the number of the discount source you would like to check:" input = gets.to_i vendor = NYCTheaterDiscounts::Vendor.all[input-1] list_deals(vendor) end |
#call ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/nyc_theater_discounts/cli.rb', line 6 def call NYCTheaterDiscounts::Scraper.load_TodayTix NYCTheaterDiscounts::Scraper.load_Theatermania NYCTheaterDiscounts::Scraper.load_BroadwayBox puts "Hello theater nerd! Here are the discount sources available:" list_vendors puts "To see a list of deals for each vendor type the number of the vendor. To search by show type 'by show'. To quit, type 'exit'." goodbye end |
#goodbye ⇒ Object
83 84 85 |
# File 'lib/nyc_theater_discounts/cli.rb', line 83 def goodbye puts "Thank you for using nyc-theater-discounts. Check back again tomorrow!" end |
#list_deals(vendor) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/nyc_theater_discounts/cli.rb', line 52 def list_deals(vendor) puts "\nTo visit #{vendor.name} go to: #{vendor.url}\n\n" vendor.shows.each_with_index do |show, index| puts "#{index+1}. #{show.name} -- available from: #{show.price}" puts "**to see this offer visit: #{show.deal_url}**\n\n" end end |
#list_vendors ⇒ Object
48 49 50 |
# File 'lib/nyc_theater_discounts/cli.rb', line 48 def list_vendors NYCTheaterDiscounts::Vendor.all.each_with_index {|value, index| puts "#{index+1}. #{value.name}"} end |
#menu(input) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nyc_theater_discounts/cli.rb', line 31 def (input) until input.to_s.downcase == "exit" if input.to_s.downcase == "by vendor" puts "To see more deals search either 'by vendor' or 'by show'. To quit type 'exit'." input = gets.strip elsif input.to_s.downcase == "by show" puts "To see more deals search either 'by vendor' or 'by show'. To quit type 'exit'." input = gets.strip else puts "Please choose either 'by vendor' or 'by show'. To quit type 'exit'." input = gets.strip end end end |
#starting_menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/nyc_theater_discounts/cli.rb', line 17 def input = gets.strip if input.to_i == 1 || input.to_i == 2 || input.to_i == 3 vendor = NYCTheaterDiscounts::Vendor.all[input.to_i-1] list_deals(vendor) puts "To see more deals search either 'by vendor' or 'by show'. To quit type 'exit'." input = gets.strip (input) else (input) end end |