Class: Tmxnews::CLI

Inherits:
Object
  • Object
show all
Includes:
HelloGoodbye
Defined in:
lib/tmxnews/cli.rb

Instance Method Summary collapse

Methods included from HelloGoodbye

#good_bye, #hello

Instance Method Details

#callObject



7
8
9
# File 'lib/tmxnews/cli.rb', line 7

def call
    menu
end


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tmxnews/cli.rb', line 11

def menu
    hello
    @article = Tmxnews::Article.list_articles
    input = nil
    while input != "exit"
        puts "Enter the number of the article you would like to read or type 'exit' to end the program."
        input = gets.strip.downcase

        if input.to_i > 0
            the_article = @article[input.to_i-1]
            puts "Headline: #{the_article.title}"
            puts "Summary: #{the_article.text}"
            puts "URL: #{the_article.url}"
        elsif input == "exit"
            good_bye
        else
            puts "Please type 'exit' or select an article number."
        end

    end
end