]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/blob - src/website.rb
1239712a696a3b855ec3ad79472865a608e7f937
[dead/whatever-dl.git] / src / website.rb
1 #
2 # Copyright Michael Orlitzky
3 #
4 # http://michael.orlitzky.com/
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # http://www.fsf.org/licensing/licenses/gpl.html
17 #
18
19 # This class keeps track of all its subclasses
20 # We use this to loop through every "website" in an
21 # attempt to determine to which site a URL belongs.
22 class Website
23 def self.inherited(subclass)
24 if superclass.respond_to? :inherited
25 superclass.inherited(subclass)
26 end
27
28 # Every time we're subclassed, add the new
29 # subclass to our list of subclasses.
30 @subclasses ||= []
31 @subclasses << subclass
32 end
33
34 def self.subclasses
35 @subclasses
36 end
37
38 # This should be overridden in any class that wants
39 # to claim ownership of a URL.
40 def self.owns_url?(url)
41 return false
42 end
43
44 # Same here. We want to default to nil unless overridden.
45 def get_video_url(url)
46 return nil
47 end
48 end