class CLI
> Handles all interfacing with our user¶ ↑
Attributes
Public Instance Methods
display_article(article)
click to toggle source
> Displays all of the article information for the user to read¶ ↑
# File lib/crowder_news/cli.rb, line 83 def display_article(article) input = nil puts "\n#{article.title}" puts "\nAuthor: #{article.author} on #{article.date}: " puts "\n\t#{article.body}" if article.youtube_links puts "\nYoutube Links:" article.youtube_links.each{ |link| puts link } end puts 'Press any key to find another article or "exit" to exit.' input = gets.strip.downcase if input == "exit" goodbye else list_articles end end
display_list(articles)
click to toggle source
goodbye()
click to toggle source
initiate()
click to toggle source
list_articles()
click to toggle source
> Lists the articles according to the user's preferences¶ ↑
# File lib/crowder_news/cli.rb, line 18 def list_articles input = nil choices = 'Choose one: recent, featured, or both. To exit type "exit".' puts choices input = gets.strip.downcase puts "" if input == "recent" puts "Recent Articles: " @articles = Article.recents display_list(@articles) menu elsif input == "featured" puts "Featured Articles: " @articles = Article.featured display_list(@articles) menu elsif input == "both" puts "All articles: " @articles = Article.all display_list(@articles) menu elsif input == "exit" goodbye else list_articles end end