Class: TutorialCentral::CLI
- Inherits:
-
Object
- Object
- TutorialCentral::CLI
- Defined in:
- lib/tutorial_central/cli.rb
Instance Method Summary collapse
- #basic_menu ⇒ Object
- #call ⇒ Object
- #category_menu ⇒ Object
- #display_tutorials(url = "http://hackr.io/latest", category = "Latest") ⇒ Object
Instance Method Details
#basic_menu ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/tutorial_central/cli.rb', line 7 def choose do || say 'Would you like to see categories or the latest tutorials?' .prompt = "You can also type 'exit' to exit." .choice(:categories) {} .choice(:latest) {display_tutorials} .hidden(:exit) {exit} end end |
#call ⇒ Object
2 3 4 5 |
# File 'lib/tutorial_central/cli.rb', line 2 def call puts "Welcome to Tutorial Central!" end |
#category_menu ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/tutorial_central/cli.rb', line 17 def categories = TutorialCentral::Scraper.scrape_categories("http://hackr.io") = categories.keys.to_a say "Here are the categories." choose do || .prompt = 'Choose one.' .choices(*) {|answer| display_tutorials(categories[answer],answer) } end end |
#display_tutorials(url = "http://hackr.io/latest", category = "Latest") ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tutorial_central/cli.rb', line 27 def display_tutorials(url="http://hackr.io/latest", category="Latest") tutorials = TutorialCentral::Scraper.scrape_tutorials(url) = tutorials.keys.to_a say "Here are the tutorials." choose do || .prompt = 'Choose one.' .choices(*) {|answer| say "#{answer} is located at #{tutorials[answer]}." } end if agree("Return to main menu?", true) else say "Thank you for using Tutorial Central!" exit end end |