class TldrNews::CLI

Public Instance Methods

again?() click to toggle source
# File lib/tldr_news/cli.rb, line 48
def again?
  puts "Read another article? (y/n)"
  input = nil
  while input != "n"
    input = gets.strip
    if input == "y"
      start
    end
  end
end
article_info(article) click to toggle source
# File lib/tldr_news/cli.rb, line 25
def article_info(article)
  puts article.headline
  puts ""
  puts article.contents.strip
  puts ""
  puts "To read even more, visit #{article.url}"
  puts "Posted #{article.time}"
end
call() click to toggle source
# File lib/tldr_news/cli.rb, line 2
def call
  puts "TLDR NEWS:"
  TldrNews::Scraper.new.make_articles
end
headline_list() click to toggle source
# File lib/tldr_news/cli.rb, line 18
def headline_list
  #this will put out a list of headlines
  TldrNews::Article.all.each.with_index(1) do |article, index|
    puts "#{index}. #{article.headline}"
  end
end
menu() click to toggle source
start() click to toggle source
# File lib/tldr_news/cli.rb, line 7
def start
  headline_list
  puts ""
  puts "If you'd like to read more about a headline, enter it's number."
  puts "Otherwise type exit"
  menu
  puts ""
  puts "Thanks Bye!"
  exit
end