Class: FiresideFinder::CLI
- Inherits:
-
Object
- Object
- FiresideFinder::CLI
- Defined in:
- lib/fireside-finder/cli.rb
Instance Attribute Summary collapse
-
#current_gatherings ⇒ Object
Returns the value of attribute current_gatherings.
-
#geoaddress ⇒ Object
Returns the value of attribute geoaddress.
-
#specific_event ⇒ Object
Returns the value of attribute specific_event.
-
#user_input ⇒ Object
Returns the value of attribute user_input.
Class Method Summary collapse
- .call ⇒ Object
- .menu ⇒ Object
- .print_all(user_input) ⇒ Object
- .print_specific(specific_event) ⇒ Object
Instance Attribute Details
#current_gatherings ⇒ Object
Returns the value of attribute current_gatherings.
8 9 10 |
# File 'lib/fireside-finder/cli.rb', line 8 def current_gatherings @current_gatherings end |
#geoaddress ⇒ Object
Returns the value of attribute geoaddress.
8 9 10 |
# File 'lib/fireside-finder/cli.rb', line 8 def geoaddress @geoaddress end |
#specific_event ⇒ Object
Returns the value of attribute specific_event.
8 9 10 |
# File 'lib/fireside-finder/cli.rb', line 8 def specific_event @specific_event end |
#user_input ⇒ Object
Returns the value of attribute user_input.
8 9 10 |
# File 'lib/fireside-finder/cli.rb', line 8 def user_input @user_input end |
Class Method Details
.call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fireside-finder/cli.rb', line 10 def self.call puts "--------------------------------------------------------------------------------" puts "Welcome to Hearthstone Fireside Gathering Finder Gem!" puts "--------------------------------------------------------------------------------" puts "Use 'new' to get back to this menu, 'exit' will close the program." puts "Please enter your address or zip-code to find local Fireside Gatherings:" user_input = gets.strip while user_input != "exit" FiresideFinder::CLI.print_all(user_input) FiresideFinder::CLI. end puts "See you at the Tavern, hero!" end |
.menu ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fireside-finder/cli.rb', line 24 def self. @user_input = nil while @user_input != "exit" @user_input = gets.strip if @user_input.to_i > 0 FiresideFinder::CLI.print_specific(@current_gatherings[@user_input.to_i - 1]) elsif @user_input == "new" FiresideFinder::Gathering.reset FiresideFinder::CLI.call elsif @user_input == "exit" puts "See you at the Tavern, hero!" exit else puts "Not sure what to do..." FiresideFinder::CLI. end end end |
.print_all(user_input) ⇒ Object
43 44 45 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 |
# File 'lib/fireside-finder/cli.rb', line 43 def self.print_all(user_input) FiresideFinder::Scraper::scrape_list(user_input) counter = 0 @current_gatherings = Array.new FiresideFinder::Gathering.all.each do |gather| counter += 1 @current_gatherings << gather puts "--------------------------------------------------------------------------------" puts counter puts "Gathering Name: #{gather.name}" puts "City: #{gather.city}" puts "Date: #{gather.date}" puts "Link to More Info: #{gather.details_link}" puts "--------------------------------------------------------------------------------" end if @current_gatherings.any? puts "" puts "Enter the number above the event you'd like more info about." FiresideFinder::CLI. else puts "--------------------------------------------------------------------------------" puts "There are no upcoming events in your area" puts "Please try a new location" puts "" puts "You will be taken back to the main menu in 10 seconds" sleep(10) system "clear" or system "cls" FiresideFinder::CLI.call end end |
.print_specific(specific_event) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/fireside-finder/cli.rb', line 74 def self.print_specific(specific_event) FiresideFinder::Scraper::scrape_specific(specific_event) puts "--------------------------------------------------------------------------------" FiresideFinder::Gathering.all.each do |gather| puts "--------------------------------------------------------------------------------" puts "Gathering Name: #{gather.name}" puts "Venue: #{gather.venue}" puts "Address: #{gather.address}" puts "Date: #{gather.datetime}" if gather.description != nil puts "Event Description: #{gather.description}" end puts "Directions: #{gather.directions}" puts "--------------------------------------------------------------------------------" end puts "--------------------------------------------------------------------------------" puts "Enter 'new' to search a new area, or 'exit' to close the program." FiresideFinder::CLI. end |