class NPRCLIApp::CLI
Public Instance Methods
call()
click to toggle source
# File lib/npr_cli_app/cli.rb, line 6 def call puts "Welcome to the NPR CLI App! Get the most up-to-date news here from NPR!" puts "-----------" top_story category_menu goodbye end
goodbye()
click to toggle source
# File lib/npr_cli_app/cli.rb, line 76 def goodbye puts "Please come back to keep up with NPR!" end
instructions()
click to toggle source
# File lib/npr_cli_app/cli.rb, line 26 def instructions puts "ENTER:" puts "- \"LIST\" to review the list of categories" puts "- \"The NAME of the CATEGORY\" to view stories related to that category" puts "- \"top story\" to view NPR's Top Story" puts "- \"instructions\" to review these instructions again" puts "- \"exit\" to leave" end
list_categories()
click to toggle source
# File lib/npr_cli_app/cli.rb, line 21 def list_categories NPRCLIApp::Story.scrape_featured.each{|story| @@categories << story.category.downcase} @@categories.uniq.each.with_index(1){|category, i| puts "#{i}. #{category.upcase}"} end
top_story()
click to toggle source
# File lib/npr_cli_app/cli.rb, line 15 def top_story puts "NPR's Top Story:" NPRCLIApp::Story.scrape_top_story.tap{|top_story| puts "#{top_story.title}"} puts "-----------" end