Class: UtahCountyAaMeetingFinder::CLI
- Inherits:
-
Object
- Object
- UtahCountyAaMeetingFinder::CLI
- Defined in:
- lib/utah_county_aa_meeting_finder/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #display_meetings(day) ⇒ Object
- #goodbye ⇒ Object
- #list_meetings ⇒ Object
- #meeting_address(day) ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/utah_county_aa_meeting_finder/cli.rb', line 3 def call puts "Welcome to Utah County AA Meeting Finder" UtahCountyAaMeetingFinder::Scraper.new.make_meetings("http://www.simeetings.com/LA/UT/OremMtgs.html") list_meetings end |
#display_meetings(day) ⇒ Object
26 27 28 29 30 |
# File 'lib/utah_county_aa_meeting_finder/cli.rb', line 26 def display_meetings(day) UtahCountyAaMeetingFinder::Meetings.find_by_day(day).each_with_index do |meeting, index| puts "#{index+1}. #{meeting.time} #{meeting.name}" end end |
#goodbye ⇒ Object
59 60 61 |
# File 'lib/utah_county_aa_meeting_finder/cli.rb', line 59 def goodbye puts "Thanks for checking in!" end |
#list_meetings ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/utah_county_aa_meeting_finder/cli.rb', line 10 def list_meetings puts "Please pick a day you would like to view meetings for" input = gets.strip if input.downcase == "exit" goodbye elsif ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"].include? input.downcase display_meetings(input) meeting_address(input) else puts "I'm sorry, I don't understand" list_meetings end end |
#meeting_address(day) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/utah_county_aa_meeting_finder/cli.rb', line 32 def meeting_address(day) puts "Please select the number of the meeting you would like directions for." meetings = UtahCountyAaMeetingFinder::Meetings.find_by_day(day) input = gets.strip if input.downcase == "exit" goodbye elsif input.to_i > meetings.size puts "There are only #{meetings.size} meetings for this day" meeting_address(day) else corrected_input = input.to_i - 1 selected_meeting = meetings[corrected_input] puts "#{selected_meeting.address}" puts "Would you like to see more meetings? Type yes or no." input = gets.strip if input.downcase == "yes" list_meetings elsif input.downcase == "no" goodbye end end end |