class TheBoards::Songs

Attributes

artist[RW]
name[RW]
prev_rank[RW]
rank[RW]

Public Class Methods

scrape_billboard() click to toggle source
# File lib/the_boards/songs.rb, line 8
def self.scrape_billboard
  songs = []
  doc = Nokogiri::HTML(open("http://www.billboard.com/charts/hot-100"))
  doc.css("div.chart-row__main-display").collect do |title|
    song = self.new
    song.name = title.css("h2").text
    song.artist = title.css("a.chart-row__artist").text.strip
    song.rank = title.css("span.chart-row__current-week").text.strip
    song.prev_rank = title.css("span.chart-row__last-week").text.strip
    songs << song
  end
  songs
end
today() click to toggle source
# File lib/the_boards/songs.rb, line 3
def self.today
  # Scrape Billboard and then return list of songs based on that data
  self.scrape_billboard
end