X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2Fwebsite.rb;h=e9e65ca1909f7add3c8b2c6ecc800a3856145528;hb=0662d93e5088ecfd2ce351910ab9a1d3568f8359;hp=4a3f2afe36a0c009a095202e9cb2eb7e405a2395;hpb=e91a9668c7be92d33a29d3645590195aaa1a3daa;p=dead%2Fwhatever-dl.git diff --git a/src/website.rb b/src/website.rb index 4a3f2af..e9e65ca 100644 --- a/src/website.rb +++ b/src/website.rb @@ -90,18 +90,28 @@ class Website # Factory method returning an instance of # the appropriate subclass. + # While we're looping through the list of subclasses, + # we'll set this to the Generic class. + generic = nil + # Check the URL against each website's class. # The class will know whether or not the URL # "belongs" to its website. @subclasses.each do |w| if w.owns_url?(url) - return w.new(url) + if w.to_s == 'Generic' + generic = w + else + # We don't want to return Generic here because some + # other subclasses further down the list might match + # the URL. + return w.new(url) + end end end - # If nothing matched, we don't return an instance - # of anything. - return nil + # If nothing matched, try the generic parser. + return generic.new(url) end