class TellyReviews::CLI
Public Instance Methods
call()
click to toggle source
# File lib/telly_reviews/cli.rb, line 3 def call puts "" puts "Welcome to Telly Reviews" puts "---------------------------------" TellyReviews::Scraper.make_list start end
print_details(review)
click to toggle source
# File lib/telly_reviews/cli.rb, line 48 def print_details(review) puts "---------------------------------" puts "#{review.title}" puts "" puts "By #{review.author}" puts "#{review.date}" puts "Twitter: #{review.author_twitter}" puts "---------------------------------" puts "" puts "#{review.body}" puts "---------------------------------" end
print_list()
click to toggle source
# File lib/telly_reviews/cli.rb, line 37 def print_list TellyReviews::Review.all.each.with_index(1) do |review, index| puts "#{index}. #{review.title} by #{review.author}" end end
print_review(review)
click to toggle source
# File lib/telly_reviews/cli.rb, line 43 def print_review(review) review.review_details print_details(review) end
start()
click to toggle source
# File lib/telly_reviews/cli.rb, line 11 def start puts "" print_list puts "---------------------------------" puts "" puts "Enter number to see article:" input = gets.strip review = TellyReviews::Review.find(input.to_i) print_review(review) puts "" puts "Type 'open' to open this article in your web browser." puts "Would you like to read another review? (y/n)" input = gets.strip.downcase if input == 'y' puts "" start elsif input == 'open' system("open", "#{review.url}") start else puts "Please come back soon for more updated reviews!" exit end end