Class: CLI
- Inherits:
-
Object
- Object
- CLI
- Defined in:
- lib/steam_deals_cli/cli.rb
Instance Method Summary collapse
- #added_info(game) ⇒ Object
- #call ⇒ Object
- #information ⇒ Object
- #more_info(list) ⇒ Object
- #print_discounts(games) ⇒ Object
- #start ⇒ Object
Instance Method Details
#added_info(game) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/steam_deals_cli/cli.rb', line 77 def added_info(game) puts "----------------------------" puts "Game: #{game.name}" puts "Developer: #{game.developer}" puts "Publisher: #{game.publisher}" puts "Discounted Price: #{game.discounted_price}" puts "% Off: #{game.price_discount}" puts "Original Price: #{game.original_price}" puts "Game URL: #{game.steam_url}" puts "----------------------------" end |
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/steam_deals_cli/cli.rb', line 3 def call Deals_Scraper.new.make_deals puts "Welcome to Steam's current sales!" start end |
#information ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/steam_deals_cli/cli.rb', line 16 def information puts "" puts "Ex. For Weeklong Deals, type '1'" puts "If you'd like to exit, type '5'" input = gets.to_i if input == 1 print_discounts(Steam_Deals.weeklong_deals) more_info(Steam_Deals.weeklong_deals) elsif input == 2 print_discounts(Steam_Deals.special_promos) more_info(Steam_Deals.special_promos) elsif input == 3 print_discounts(Steam_Deals.daily_deals) more_info(Steam_Deals.daily_deals) elsif input == 4 print_discounts(Steam_Deals.weekend_deals) more_info(Steam_Deals.weekend_deals) elsif input == 5 puts "Thanks! If you'd like to see more deals com'on back!" else puts "#{input} is invalid. Please try again." information end end |
#more_info(list) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/steam_deals_cli/cli.rb', line 54 def more_info(list) puts "Would you like to see more info on any of the games on the list?" puts "Yes to continue and No to end the program." info_request = gets.chomp if info_request.downcase == "yes" puts "" puts "Which would you like to know more about?" input = gets.to_i puts "" puts "#{list[input-1].name}" Steam_Deals.additional_info(list[input-1]) added_info(list[input-1]) more_info(list) elsif info_request.downcase == "no" puts "Thanks! If you'd like to see more deals com'on back!" elsif info_request.downcase == "eggs" puts "Easter" else puts "#{info_request} is invalid. Please try again." more_info(list) end end |
#print_discounts(games) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/steam_deals_cli/cli.rb', line 42 def print_discounts(games) games.each_with_index do |game, index| puts "----------------------------" puts "" puts "#{index+1}." puts "Game: #{game.name}" puts "Discounted Price: #{game.discounted_price}" puts "% Off: #{game.price_discount}" puts "" end end |
#start ⇒ Object
9 10 11 12 13 14 |
# File 'lib/steam_deals_cli/cli.rb', line 9 def start puts "-----------------------------------------" puts "\nWhich would you like to see? There are currently #{Deals_Scraper.new.current_deals_count} products on sale." puts "\nHow would you like to see them sorted? Would you like to view the Weeklong Deals, Special Promotoions, Daily Deals, or Weekend Deals " information end |