Class: MmorpgNews::CLI
- Inherits:
-
Object
- Object
- MmorpgNews::CLI
- Defined in:
- lib/mmorpg_news/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
3 4 5 6 |
# File 'lib/mmorpg_news/cli.rb', line 3 def call list_stories end |
#goodbye ⇒ Object
43 44 45 |
# File 'lib/mmorpg_news/cli.rb', line 43 def goodbye puts "Thank you for using MMORPG news Gem!" end |
#list_stories ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mmorpg_news/cli.rb', line 8 def list_stories puts "\e[H\e[2J" puts "MMORPG's top news stories:" puts "" @story_items = MmorpgNews::GameNews.create_stories @story_items.each.with_index(1) do |story, i| puts "#{i}. #{story.title}" puts "Posted #{story.date.first} by #{story.}" end end |
#menu ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mmorpg_news/cli.rb', line 19 def input = nil while input != "exit" puts "\nEnter the number of the news story you would like to read:" puts "Type 'list' to see the article list again or 'exit' to exit:" input = gets.strip.downcase if input.to_i > 0 && @story_items[input.to_i-1] != nil the_story = @story_items[input.to_i-1] puts "\e[H\e[2J" puts "#{the_story.title}" puts "Posted #{the_story.date.first} by #{the_story.}" puts "\n#{MmorpgNews::GameNews.get_story(the_story.link)}" puts "\n#{the_story.link}" elsif input == "list" list_stories elsif input == "exit" puts "\e[H\e[2J" goodbye else puts "invalid entry!" end end end |