Class: TldrNews::CLI
- Inherits:
-
Object
- Object
- TldrNews::CLI
- Defined in:
- lib/tldr_news/cli.rb
Instance Method Summary collapse
- #again? ⇒ Boolean
- #article_info(article) ⇒ Object
- #call ⇒ Object
- #headline_list ⇒ Object
- #menu ⇒ Object
- #start ⇒ Object
Instance Method Details
#again? ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 |
# 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) ⇒ Object
25 26 27 28 29 30 31 32 |
# 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 ⇒ Object
2 3 4 5 |
# File 'lib/tldr_news/cli.rb', line 2 def call puts "TLDR NEWS:" TldrNews::Scraper.new.make_articles end |
#headline_list ⇒ Object
18 19 20 21 22 23 |
# 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 ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tldr_news/cli.rb', line 34 def input = gets.strip if input == "" puts "" puts "I don't get it." else puts "" art = TldrNews::Article.find(input) article_info(art) puts "" end again? end |
#start ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# 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" puts "" puts "Thanks Bye!" exit end |