Class: Trendster::CLI
- Inherits:
-
Object
- Object
- Trendster::CLI
- Defined in:
- lib/trendster/cli.rb
Instance Method Summary collapse
-
#call ⇒ Object
domino order of methods to run.
- #goodbye ⇒ Object
-
#list_events ⇒ Object
should list current library events.
- #make_events ⇒ Object
- #menu ⇒ Object
Instance Method Details
#call ⇒ Object
domino order of methods to run
5 6 7 8 9 10 |
# File 'lib/trendster/cli.rb', line 5 def call make_events list_events goodbye end |
#goodbye ⇒ Object
53 54 55 |
# File 'lib/trendster/cli.rb', line 53 def goodbye puts "See you next time for more library events!" end |
#list_events ⇒ Object
should list current library events
19 20 21 22 23 24 25 |
# File 'lib/trendster/cli.rb', line 19 def list_events puts "Here are the most recent events at the Cuyahoga County Public Library:" all_events = Trendster::Event.all all_events.each do |event| puts "#{all_events.index(event) + 1}. #{event.name}" end end |
#make_events ⇒ Object
12 13 14 15 |
# File 'lib/trendster/cli.rb', line 12 def make_events events_array = Trendster::Scraper.scrape_library_page Trendster::Event.create_from_collection(events_array) end |
#menu ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/trendster/cli.rb', line 27 def input = nil while input != "exit" puts "Enter the number of the event you'd like more info on, 'list' to see the events again, or type 'exit'." input = gets.strip if input.to_i > 0 && Trendster::Event.all[input.to_i - 1] != nil selected_event = Trendster::Event.all[input.to_i - 1] puts selected_event.name puts selected_event.description puts selected_event.date puts "Location: #{selected_event.location}" puts "Audience: #{selected_event.audience}" elsif input == "list" list_events elsif input == "exit" break else puts "Please enter a valid number, 'list' or 'exit'" end end end |