Sha256: b24a895ffbafb3eb38b5fadda73a9d374e553b5a336ac846d20d9604af7697b6

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

class DutchTop40::Songs

    attr_accessor :title, :name, :listed, :last_week_rank

    @@all = []


    def self.list
        self.scrape_songs
    end

    def self.scrape_songs
        songs = []
        doc = Nokogiri::HTML(open("http://top40.nl"))
        doc.search('.listScroller').search('.top40List').each do |song|
            songs << {
                :title => song.search('.songtitle').text.strip,
                :name => song.search('.artist').text,
                :listed => song.search('.details').text.split(' | ')[1].gsub(/Aantal weken: /,'').strip,
                :last_week_rank => song.search('.details').text.split(' | ')[0].gsub(/Vorige week: #/,'').strip
        }
        end
        songs
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dutch_top40-0.1.0 lib/dutch_top40/songs.rb