class BillboardCharts

Public Class Methods

new(chart_name='hot-100') click to toggle source
# File lib/udacicharts.rb, line 8
def initialize(chart_name='hot-100')
  url = 'http://www.billboard.com/charts/'+chart_name
  @scraped_data = Nokogiri::HTML(open(url))
end

Public Instance Methods

get_artists() click to toggle source
# File lib/udacicharts.rb, line 13
def get_artists
  @scraped_data.css(".chart-row__artist").collect do |artist|
    artist.text.strip!
  end
end
get_list(limit=100) click to toggle source
# File lib/udacicharts.rb, line 25
def get_list(limit=100)
  @limit=limit
  get_artists.zip(get_singles)
end
get_singles() click to toggle source
# File lib/udacicharts.rb, line 19
def get_singles
  @scraped_data.css(".chart-row__song").collect do |song|
    song.text
  end
end