class BillboardChartScraper
encoding: utf-8
Attributes
scraped_data[RW]
Public Class Methods
new(url)
click to toggle source
# File lib/billboard_chart/billboard_chart_scraper.rb, line 9 def initialize(url) @scraped_data = Nokogiri::HTML(open(url)) top_ten end
Public Instance Methods
get_artists()
click to toggle source
get_singles()
click to toggle source
# File lib/billboard_chart/billboard_chart_scraper.rb, line 20 def get_singles @scraped_data.css("h1").collect {|single| single.text}[1..10] end
merge_artists_and_singles()
click to toggle source
# File lib/billboard_chart/billboard_chart_scraper.rb, line 24 def merge_artists_and_singles Hash[get_artists.zip(get_singles)] end
top_ten()
click to toggle source
Display Methods ============= #¶ ↑
# File lib/billboard_chart/billboard_chart_scraper.rb, line 30 def top_ten puts "\n" puts "✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭".yellow puts "\n" puts " ♫ Top 10 Billboard Hot 100 Singles Chart: ♫ " puts " (#{DateTime.now.strftime('%m/%d/%Y')}) ".red puts "\n" i = 0 while i < 10 merge_artists_and_singles.each do |artist, single| puts "#{i+1}. #{artist} - #{single}" i += 1 end puts "\n" puts "✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭ ✭".yellow puts "\n" end end