Class: PrRuby::CLI
- Inherits:
-
Object
- Object
- PrRuby::CLI
- Defined in:
- lib/pr_ruby/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 |
# File 'lib/pr_ruby/cli.rb', line 3 def call puts "Welcome to Practicing Ruby!" PrRuby::Scraper.new.scrape_article_info goodbye end |
#goodbye ⇒ Object
46 47 48 |
# File 'lib/pr_ruby/cli.rb', line 46 def goodbye puts "Thanks for taking a look!" end |
#list_articles ⇒ Object
10 11 12 13 14 15 |
# File 'lib/pr_ruby/cli.rb', line 10 def list_articles puts "Here is a list of Ruby Articles to browse:" PrRuby::Letter.all.each_with_index do |letter, i| puts "#{i+1}. #{letter.title}" end end |
#menu ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pr_ruby/cli.rb', line 17 def list_articles input = nil while input != "exit" puts "Enter the number of the article you would like to read." input = gets.strip.downcase if input.to_i <= PrRuby::Letter.all.size letter = PrRuby::Letter.all[input.to_i-1] puts "Title: #{letter.title}" puts "Summary: #{letter.summary}" puts "Would you like to read the rest of the article? If not please type 'list' to return to the list of articles or 'exit' to exit the program." answer = gets.strip.upcase if answer == "YES" || answer == "Y" puts letter.content elsif answer == "LIST" list_articles else "" goodbye exit end end end end |