Class: DailyTrending::Cli
- Inherits:
-
Object
- Object
- DailyTrending::Cli
- Defined in:
- lib/daily_trending/cli.rb
Instance Method Summary collapse
Instance Method Details
#app_info(app) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/daily_trending/cli.rb', line 42 def app_info(app) xml_info = DailyTrending::Scraper.scrape_app(app.app_url) app.make_app(xml_info) puts " \#{app.title.upcase.colorize(:blue)}\n Developers: \#{app.dev}\n Content For: \#{app.con_rating}\n Rated By: \#{app.rate_cnt}\n\n DOC\n puts \"DESCRIPTION:\".colorize(:red)\n puts <<-DOC\n\n \#{app.description}\n\n Get App At: \#{app.app_url.colorize(:red)}\n More Apps By \#{app.dev}: \#{app.dev_url.colorize(:red)}\n\n DOC\n input = nil\n puts \" Type 'list' to see apps again or 'exit' to leave\"\n until input == 'list'|| input == 'exit'\n input = gets.strip.downcase\n if input == 'list'\n list_apps\n elsif input == 'exit'\n goodbye\n exit\n else\n puts \" \#{input} not an option, type list or exit\" unless input == 'exit'\n end\n end\nend\n" |
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/daily_trending/cli.rb', line 3 def call list_apps goodbye end |
#goodbye ⇒ Object
77 78 79 |
# File 'lib/daily_trending/cli.rb', line 77 def goodbye puts "See you next time!!" end |
#list_apps ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/daily_trending/cli.rb', line 9 def list_apps s = "******".colorize(:red) puts "" puts " #{s}"+"New And Updated Apps!"+s puts "" @apps = DailyTrending::Scraper.make_apps unless @apps != nil @apps.each.with_index(1) do |app, i| puts " \#{i}. \#{app.title.colorize(:blue)}\n \#{app.rating} Cost: \#{app.price}\n\n DOC\n end\n puts \"\"\nend\n" |
#menu ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/daily_trending/cli.rb', line 26 def input = nil until input == 'exit' puts "Enter the number of the app you'd like more info on, or type exit" input = gets.strip.downcase if input.to_i > 0 app_info(@apps[input.to_i-1]) elsif input == 'list' list_apps else puts "#{input} not an option, type list or exit" unless input == 'exit' end end end |