Class: TldrNews::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/tldr_news/cli.rb

Instance Method Summary collapse

Instance Method Details

#again?Boolean

Returns:

  • (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)
  puts article.headline
  puts ""
  puts article.contents.strip
  puts ""
  puts "To read even more, visit #{article.url}"
  puts "Posted #{article.time}"
end

#callObject



2
3
4
5
# File 'lib/tldr_news/cli.rb', line 2

def call
  puts "TLDR NEWS:"
  TldrNews::Scraper.new.make_articles
end

#headline_listObject



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


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/tldr_news/cli.rb', line 34

def menu
    input = gets.strip
    if input == ""
      puts ""
      puts "I don't get it."
    else
      puts ""
      art = TldrNews::Article.find(input)
      (art)
      puts ""
    end
    again?
end

#startObject



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"
  menu
  puts ""
  puts "Thanks Bye!"
  exit
end