Class: SnesFinderCliApp::CLI
- Inherits:
-
Object
- Object
- SnesFinderCliApp::CLI
- Defined in:
- lib/snes_finder_cli_app/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #now_what ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
2 3 4 5 6 |
# File 'lib/snes_finder_cli_app/cli.rb', line 2 def initialize @bestbuy = SnesFinderCliApp::BestBuy.new @amazon = SnesFinderCliApp::Amazon.new @target = SnesFinderCliApp::Target.new end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/snes_finder_cli_app/cli.rb', line 8 def call puts "\nLet's see if the SNES Classic is in available for purchase." puts "\nChecking Best Buy. This might take a minute..." bestbuy = @bestbuy.scraper puts "Now checking Amazon..." amazon = @amazon.scraper puts "Checking Target now, just a bit longer..." target = @target.scraper puts "\nHere are the current listings for SNES Classic" puts "1. Best Buy - #{bestbuy}" puts "2. Amazon - #{amazon}" puts "3. Target - #{target}" puts "\nType the number of the link you are interested in, or type refresh or exit." now_what end |
#now_what ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/snes_finder_cli_app/cli.rb', line 28 def now_what input = gets.strip if input.downcase == "exit" puts "Come again soon!" elsif input.downcase == "refresh" call elsif input.to_i == 1 puts "\n#{@bestbuy.more_info}" puts "\n#{@bestbuy.url}\n" puts "\nAnything else?" now_what elsif input.to_i == 2 puts "\n#{@amazon.more_info}" puts "\n#{@amazon.url}\n" puts "\nAnything else?" now_what elsif input.to_i == 3 puts "\n#{@target.more_info}" puts "\n#{@target.url}\n" puts "\nAnything else?" now_what else puts "Type either 1-3, refresh, or exit." now_what end end |