class ShowListings::Scraper
Public Class Methods
new(home, venue_choice=nil)
click to toggle source
# File lib/show_listings/scraper.rb, line 3 def initialize(home, venue_choice=nil) @home = home @venue_choice = venue_choice end
Public Instance Methods
buy_info_choice()
click to toggle source
# File lib/show_listings/scraper.rb, line 115 def buy_info_choice listing = ShowListings::Listing.new(@home, @input_int) if @home.css(".ds-event-category-music")[@input_int-1].to_s.include?("ds-buy-tix") puts "\nWould you like to buy tickets for that show or just get more info?" buy_or_info = gets.chomp.downcase while (!buy_or_info.include?("tix") && !buy_or_info.include?("tick") && !buy_or_info.include?("info") && !buy_or_info.include?("buy")) puts "\nI didn't understand your input. Would you like to buy tickets for that show, or simply learn more information?" buy_or_info = gets.chomp.downcase end if (buy_or_info.include?("tix") || buy_or_info.include?("tick") || buy_or_info.include?("buy")) listing.open_buy elsif buy_or_info.include?("info") listing.open_info end else listing.open_info end end
date_choice()
click to toggle source
# File lib/show_listings/scraper.rb, line 44 def date_choice if @home.css(".ds-paging").text.strip.include?("Next Page") puts "If you'd like to learn about one of these shows, please enter its number. If you'd like to see more shows, type 'more'. If you're done, type 'done.'" today_menu else puts "You've reached the end of today's listings. Choose the number of the show you're interested in, type 'done' if you're done, or type 'restart' to go back to the beginning of today's listings." today_menu end end
numbered_list()
click to toggle source
# File lib/show_listings/scraper.rb, line 29 def numbered_list puts @home.css('.ds-event-category-music').each_with_index do |event, idx| if @today == true puts "#{idx+1}. " + event.css(".ds-venue-name").text.strip elsif @today == false puts "#{idx+1}. " + event.css(".ds-event-date").text.strip end puts event.css(".ds-listing-event-title-text").text.strip puts event.css(".ds-event-time").text.strip.split(" ").first puts "\n" @num +=1 end end
today()
click to toggle source
# File lib/show_listings/scraper.rb, line 8 def today @today = true @page = 1 @num = 1 puts "\nloading today's shows..." puts sleep(0.5) numbered_list date_choice end
venue()
click to toggle source
# File lib/show_listings/scraper.rb, line 19 def venue @today = false @num = 1 @page = 2 @last_page = false numbered_list puts "Would you like to find out more about any of these shows? If so, enter the show's number. If you want to see more shows, type 'more'. If you're done, type 'done'." venue_menu end