23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/markets/cli.rb', line 23
def
input = nil
while input != "exit"
puts "\nEnter the number of the news story you would like to read or type 'list' to see the article list again or 'exit' to exit:"
input = gets.strip.downcase
if input.to_i > 0 && @story_items[input.to_i-1] != nil
the_story = @story_items[input.to_i-1]
puts "\e[H\e[2J"
puts "\t#{the_story.title}\n"
puts "\n\tPublished on #{the_story.date.first}\tWritten by #{the_story.author}\n"
puts "\n\tStory summary: "
puts "\t#{the_story.content}"
puts "\nRead more here by following this link:\nhttps://www.theatlantic.com#{the_story.link}"
elsif input == "list"
list_stories
elsif input == "exit"
puts "\e[H\e[2J"
end_program
else
puts "Error, please enter the number of the story you wish to read!"
end
end
end
|