Class: OrlandoEvents::CLI
- Inherits:
-
Object
- Object
- OrlandoEvents::CLI
- Defined in:
- lib/orlando_events/cli.rb
Overview
CLI Controller
Instance Method Summary collapse
- #add_attributes_to_months ⇒ Object
- #call ⇒ Object
- #goodbye ⇒ Object
- #list_dates ⇒ Object
- #make_months ⇒ Object
- #menu ⇒ Object
Instance Method Details
#add_attributes_to_months ⇒ Object
21 22 23 24 25 26 |
# File 'lib/orlando_events/cli.rb', line 21 def add_attributes_to_months OrlandoEvents::Event.all.each do |month| events = OrlandoEvents::Scraper.scrape_event_info(month.month_url) month.add_event_details(events) end end |
#call ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/orlando_events/cli.rb', line 4 def call puts "Loading Events..." puts "." make_months puts ".." add_attributes_to_months puts "..." list_dates goodbye end |
#goodbye ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/orlando_events/cli.rb', line 75 def goodbye puts "" puts "**********************************".colorize(:yellow) puts "Have a nice day!" puts "Be sure to come back soon for more fun events!" puts "**********************************".colorize(:yellow) puts "" end |
#list_dates ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/orlando_events/cli.rb', line 28 def list_dates puts "***************************************************".colorize(:green) puts "* *".colorize(:green) puts "* Welcome to the Orlando Event Tracker! *".colorize(:green) puts "* *".colorize(:green) puts "***************************************************".colorize(:green) puts "" puts "Downtown has so much to offer everyone, who lives, works and plays in Central Florida. Check out what's going on in and around Downtown Orlando!" puts "" puts "**********************************".colorize(:yellow) @dates = OrlandoEvents::Event.all @dates.each.with_index(1) do |date, i| puts "#{i}. #{date.name}".colorize(:light_cyan) end puts "**********************************".colorize(:yellow) end |
#make_months ⇒ Object
16 17 18 19 |
# File 'lib/orlando_events/cli.rb', line 16 def make_months months_array = OrlandoEvents::Scraper.scrape_dates("http://www.downtownorlando.com/future/events/") OrlandoEvents::Event.create_from_collection(months_array) end |
#menu ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/orlando_events/cli.rb', line 46 def input = nil while input != "exit" puts "Which month's events would you like to see? Enter" + " number".colorize(:green) + " associated with month:" puts "Enter " + "list".colorize(:green) + " to see months again or enter " + "exit".colorize(:green) + " to quit program." input = gets.strip if input.to_i > 0 && input.to_i <= @dates.length puts "**** Events for#{@dates[input.to_i-1].name} ****".colorize(:yellow) puts "" @dates[input.to_i-1].events.each.with_index(1) do |event, i| puts "#{i}. Event: #{event.event_title}".colorize(:light_green) puts " Date: #{event.date}".colorize(:light_blue) puts " Location: #{event.event_location}".colorize(:light_red) puts "------------------------------------------".colorize(:yellow) end puts "**** Events for#{@dates[input.to_i-1].name} ****".colorize(:yellow) puts "" elsif input == "list" list_dates else if input != "exit" puts "" puts "DOES NOT COMPUTE. Enter " + "number".colorize(:green) + " of month," + " 'list' ".colorize(:green) + "or " + "exit".colorize(:green) puts "" end end end end |