9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/sport_headlines/cli.rb', line 9
def start
sites = SportHeadlines::Site.all
scraper = SportHeadlines::Scraper
puts ""
input = nil
while input != 'exit'
puts "Please select a site - by number you would like to view the top headlines from. Enter exit to end the program"
puts ""
list_sites
puts ""
input = gets.strip
if input.to_i.between?(1,sites.size)
scraper.scrape_site_headlines(sites[input.to_i-1])
puts "Select an article to read its content."
puts ""
sites[input.to_i-1].list_articles
article_input = gets.strip
scraper.scrape_article(sites[input.to_i-1].articles[article_input.to_i - 1])
sites[input.to_i-1].articles[article_input.to_i - 1].print_content
end
end
end
|