Class: CourseraDownloader::Policy
- Inherits:
-
Object
- Object
- CourseraDownloader::Policy
- Defined in:
- lib/coursera_downloader/policy.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ Policy
constructor
A new instance of Policy.
- #url_action(url) ⇒ Object
Constructor Details
#initialize(file) ⇒ Policy
Returns a new instance of Policy.
5 6 7 8 9 10 11 12 13 |
# File 'lib/coursera_downloader/policy.rb', line 5 def initialize(file) @patterns = YAML::load(File.read(file)) @patterns.each_pair do |group, patterns| @patterns[group] = patterns.map do |pattern| Regexp.new(pattern) end end end |
Instance Method Details
#url_action(url) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/coursera_downloader/policy.rb', line 15 def url_action(url) return :none if !url || (url.scheme && !(url.scheme != "http" || url.scheme != "https")) url = url.to_s return :disable if disable_url?(url) return :download if download_url?(url) end |