Class: MeetupScraper::CommandLineInterface
- Inherits:
-
Object
- Object
- MeetupScraper::CommandLineInterface
- Defined in:
- lib/meetup_scraper/command_line_interface.rb
Instance Attribute Summary collapse
-
#climethods ⇒ Object
readonly
Returns the value of attribute climethods.
Instance Method Summary collapse
-
#initialize ⇒ CommandLineInterface
constructor
A new instance of CommandLineInterface.
- #print_meetup_event ⇒ Object
- #print_meetup_events ⇒ Object
- #run ⇒ Object
- #run_again ⇒ Object
Constructor Details
#initialize ⇒ CommandLineInterface
Returns a new instance of CommandLineInterface.
4 5 6 |
# File 'lib/meetup_scraper/command_line_interface.rb', line 4 def initialize @climethods = MeetupScraper::CliMethods.new end |
Instance Attribute Details
#climethods ⇒ Object (readonly)
Returns the value of attribute climethods.
2 3 4 |
# File 'lib/meetup_scraper/command_line_interface.rb', line 2 def climethods @climethods end |
Instance Method Details
#print_meetup_event ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/meetup_scraper/command_line_interface.rb', line 27 def print_meetup_event input = self.climethods.pick_meetup_event if (input.to_i >= 1 && input.to_i <= MeetupScraper::Event.all.size) event = MeetupScraper::Event.all[input.to_i - 1] url = event.url # down load event's details, update event attributes & print event updated_details = self.climethods.fetch_event_details(url) updated_event = event.update_event_attributes(updated_details) self.climethods.print_event(updated_event) self.run_again elsif input == '0' self.run elsif input == 'exit' puts 'Good bye!' else puts 'Selection not recognised, try again' print_meetup_event end end |
#print_meetup_events ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/meetup_scraper/command_line_interface.rb', line 15 def print_meetup_events events = MeetupScraper::Event.all while events.size < 1 puts "Sorry, no matches found, try again." puts '------------------------------------' self.run end self.climethods.print_events self.print_meetup_event #self.run end |
#run ⇒ Object
8 9 10 11 12 13 |
# File 'lib/meetup_scraper/command_line_interface.rb', line 8 def run url = self.climethods.get_user_input event_hashes = climethods.search_meetup(url) climethods.create_events_from_hashes(event_hashes) self.print_meetup_events end |
#run_again ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/meetup_scraper/command_line_interface.rb', line 47 def run_again puts "Enter '1' to view listing again or '0' to search again" input = gets.chomp if input.to_i == 1 self.print_meetup_events elsif input == '0' self.run else puts 'Selection not recognised, try again' run_again end end |