Class: Jukebox::Concert

Inherits:
Object
  • Object
show all
Defined in:
lib/jukebox/concert.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#artist_nameObject

Returns the value of attribute artist_name.



2
3
4
# File 'lib/jukebox/concert.rb', line 2

def artist_name
  @artist_name
end

#dateObject

Returns the value of attribute date.



2
3
4
# File 'lib/jukebox/concert.rb', line 2

def date
  @date
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/jukebox/concert.rb', line 2

def location
  @location
end

#urlObject

Returns the value of attribute url.



2
3
4
# File 'lib/jukebox/concert.rb', line 2

def url
  @url
end

Class Method Details

.scrape_concertsObject



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