Class: Threecast::CLI
- Inherits:
-
Object
- Object
- Threecast::CLI
- Defined in:
- lib/threecast/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
2 3 4 5 6 |
# File 'lib/threecast/cli.rb', line 2 def call list_stories goodbye end |
#goodbye ⇒ Object
41 42 43 44 |
# File 'lib/threecast/cli.rb', line 41 def goodbye puts "Check back for the latest news." exit end |
#list_stories ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/threecast/cli.rb', line 8 def list_stories puts "" puts "Welcome to Threecast" puts "Here are today's top news stories:" puts "------------------------------------" puts "" @news = Threecast::News.today @news.each.with_index(1) do |story, i| puts "(#{i}) #{story.network} - #{story.date}: #{story.story}" puts "" unless i == 3 end end |
#menu ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/threecast/cli.rb', line 22 def input = nil while input != 'exit' puts "------------------------------------" puts "Enter the story number to open in your browser or exit:" input = gets.strip.downcase if input.to_i.between?(1,3) open_up = @news[input.to_i - 1] system("open", "#{open_up.url}") list_stories else puts "Please enter a number or exit." end end goodbye end |