Class: DownThemAll::Manager
- Inherits:
-
Object
- Object
- DownThemAll::Manager
- Defined in:
- lib/downthemall/manager.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Manager
constructor
A new instance of Manager.
- #queue(url, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Manager
Returns a new instance of Manager.
7 8 9 10 11 |
# File 'lib/downthemall/manager.rb', line 7 def initialize(={}) @download_path = [:download_path] || File.('~/Downloads') @database_file = [:database_file] || File.join(Firefox::Profile.path, "dta_queue.sqlite") @queue = Sequel.sqlite(:database => @database_file)[:queue] end |
Instance Method Details
#queue(url, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/downthemall/manager.rb', line 13 def queue(url, ={}) [:subpath] ||= '' [:filename] ||= File.basename(url) [:referrer] ||= '' [:position] ||= 0 path_name = File.join(@download_path, [:subpath]) data =<<DATA {"fileName":"#{ [:filename] }","postData":null,"numIstance":13,"description":"","resumable":true,"mask":"*name*.*ext*","pathName":"#{ path_name }","compression":null,"maxChunks":4,"contentType":"","conflicts":0,"fromMetalink":false,"state":2,"referrer":"#{ [:referrer] }","startDate":1278559024057,"urlManager":[{"url":"#{ url }","charset":"ISO-8859-1","preference":100}],"visitors":[],"totalSize":0,"chunks":[]} DATA @queue << { :pos => [:position], :item => data } end |