Class: CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/top_free_apps_itunes/cli.rb

Instance Method Summary collapse

Instance Method Details



15
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
41
42
43
44
45
46
# File 'lib/top_free_apps_itunes/cli.rb', line 15

def menu

    puts ""
    puts "Please enter the number of the app to view its details or 'exit' to end the program:"

    input = gets.chomp

    #app = App.all[input.to_i - 1]

    if input.to_i > 0 && input.to_i <=App.all.size
        app = App.all[input.to_i - 1]
        Scraper.scrape_app_details(app)
        puts ""
        puts "#{app.title}"
        puts "Category: #{app.category}"
        puts "Developer: #{app.developer}"
        puts "Rating: #{app.rating}"
        puts "Languages: #{app.language}"
        puts "Size: #{app.size}"
        menu
    elsif input == "exit"
        puts""
        puts "Thank you and goodbye!"
        puts ""
        exit
    else
        puts ""
        puts "Invalid choice... please select again"
        menu
    end
    
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/top_free_apps_itunes/cli.rb', line 3

def run
    puts "Welcome to iTunes' Top Free Apps List!"

    Scraper.scrape_itunes

    App.all.each.with_index(1) do |app, i|
        puts "#{i}. #{app.title}"
    end

    menu
end