Class: Applist::CLI
- Inherits:
-
Object
- Object
- Applist::CLI
- Defined in:
- lib/applist/cli.rb
Instance Attribute Summary collapse
-
#avg_rating ⇒ Object
Returns the value of attribute avg_rating.
-
#category ⇒ Object
Returns the value of attribute category.
-
#desc ⇒ Object
Returns the value of attribute desc.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#avg_rating ⇒ Object
Returns the value of attribute avg_rating.
2 3 4 |
# File 'lib/applist/cli.rb', line 2 def @avg_rating end |
#category ⇒ Object
Returns the value of attribute category.
2 3 4 |
# File 'lib/applist/cli.rb', line 2 def category @category end |
#desc ⇒ Object
Returns the value of attribute desc.
2 3 4 |
# File 'lib/applist/cli.rb', line 2 def desc @desc end |
#link ⇒ Object
Returns the value of attribute link.
2 3 4 |
# File 'lib/applist/cli.rb', line 2 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/applist/cli.rb', line 2 def name @name end |
Instance Method Details
#call ⇒ Object
4 5 6 7 8 |
# File 'lib/applist/cli.rb', line 4 def call list_apps goodbye end |
#goodbye ⇒ Object
36 37 38 |
# File 'lib/applist/cli.rb', line 36 def goodbye puts "Lata sucka!" end |
#list_apps ⇒ Object
10 11 12 13 14 15 |
# File 'lib/applist/cli.rb', line 10 def list_apps @apps = Applist::Apps.popular @apps.each.with_index(1) do | app, i | puts "#{i}. #{app[:name][0]} in #{app[:category][0]}." end end |
#menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/applist/cli.rb', line 17 def puts "This is a list of the most popular free apps available on the Apple App Store. Please enter the number for the app you would like to view. Type list to see the list again or type exit to leave:" input = nil while input != "exit" input = gets.strip.downcase if input.to_i > 0 the_app = @apps[input.to_i - 1] puts "#{the_app[:name][0]} in #{the_app[:category][0]}." puts "Average Rating: #{the_app[:avg_rating]}" puts "#{the_app[:desc]}" puts "Please type the number of the app you are interested in, list to see them again, or exit to leave." elsif input == "list" list_apps else puts "Please type the number of the app you are interested in, list to see them again, or exit to leave." end end end |