class BcCrawler::Main
Attributes
releases[RW]
url[RW]
Public Class Methods
new(url)
click to toggle source
# File lib/bc_crawler/main.rb, line 10 def initialize(url) @url = url @releases = [] # call the page html = open(@url).read release_paths = Set.new # get all "a" elements that target an /album/... URL html.scan(/<a href="\/album\/(.*?)"/).each { |r| release_paths << "/album/#{r.first}" } # TODO: implement single tracks, that are not assigned to an album, but directly to the artist # initialize the release(s) release_paths.each do |path| @releases << BcCrawler::Release.new("#{ @url }#{ path }") end end
Public Instance Methods
crawl()
click to toggle source
# File lib/bc_crawler/main.rb, line 29 def crawl # fetch information about the release @releases.each do |release| release.crawl end end
to_s()
click to toggle source
# File lib/bc_crawler/main.rb, line 36 def to_s <<-EOF URL : #{ @url } Number of releases : #{ @releases.count } EOF end