Sha256: 5ed4571182e1a934fb9c2e7811e3ddc9fd940676690011c74bb7703078445268

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

class NewsReader::CLI
    APP_NAME = "News Reader CLI"
    def self.start
        NewsReader::Article.import(NewsReader::Scraper.fetch_articles)

        puts "----- Welcome to the News Reader CLI app! ----"
        puts "--"

        input = nil
        while input != "exit"
            menu
            input = gets.strip

            case input
                when 'list'
                    NewsReader::Article.list
                when 'read'
                    NewsReader::Article.read
                when 'about'
                    about
            end
        end

        puts "Thanks for using the #{APP_NAME} app!"
    end

    def self.menu
        puts "\n"
        puts "------- Menu --------"
        puts "Please choose an option from the menu below:"
        puts "   - Type `list` to list all the articles"
        puts "   - Type `read` to read an article"
        puts "   - Type `about` to know more about #{APP_NAME}"
        puts "   - Type `exit` to exit the app."
        puts "-"
    end

    def self.about
        puts "News Reader CLI app by JGB Solutions. Visit https://jgb.solutions for more."
    end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
news_reader-0.1.3 lib/news_reader/cli.rb
news_reader-0.1.2 lib/news_reader/cli.rb
news_reader-0.1.1 lib/news_reader/cli.rb
news_reader-0.1.0 lib/news_reader/cli.rb