Class: Jukebox::Concert
- Inherits:
-
Object
- Object
- Jukebox::Concert
- Defined in:
- lib/jukebox/concert.rb
Instance Attribute Summary collapse
-
#artist_name ⇒ Object
Returns the value of attribute artist_name.
-
#date ⇒ Object
Returns the value of attribute date.
-
#location ⇒ Object
Returns the value of attribute location.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#artist_name ⇒ Object
Returns the value of attribute artist_name.
2 3 4 |
# File 'lib/jukebox/concert.rb', line 2 def artist_name @artist_name end |
#date ⇒ Object
Returns the value of attribute date.
2 3 4 |
# File 'lib/jukebox/concert.rb', line 2 def date @date end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/jukebox/concert.rb', line 2 def location @location end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/jukebox/concert.rb', line 2 def url @url end |
Class Method Details
.scrape_concerts ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/jukebox/concert.rb', line 4 def self.scrape_concerts @concert_list = [] #Opens the memphis eventful concert website and saves the HTML to doc doc = Nokogiri::HTML(open("http://memphis.eventful.com/events/categories/music")) #Saves the list of concerts concerts = doc.css("li.clearfix") #Scrapes information about a concert and creates a corresponding object concerts.each do |concert| new_concert = self.new new_concert.artist_name = concert.css("h4").text new_concert.date = concert.css(".event-meta strong").text new_concert.location = concert.css(".event-meta span").text new_concert.url = concert.css("h4 a").attr("href") #adds the object to the @concert_list array @concert_list << new_concert end #Returns the concert_list array @concert_list end |