Class: Jaxx::Download
- Inherits:
-
Object
- Object
- Jaxx::Download
- Defined in:
- lib/jaxx/download.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#process ⇒ Object
readonly
Returns the value of attribute process.
Instance Method Summary collapse
- #execute ⇒ Object
- #files(directory) ⇒ Object
-
#initialize(args = {}) ⇒ Download
constructor
A new instance of Download.
Constructor Details
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'lib/jaxx/download.rb', line 6 def filename @filename end |
#process ⇒ Object (readonly)
Returns the value of attribute process.
6 7 8 |
# File 'lib/jaxx/download.rb', line 6 def process @process end |
Instance Method Details
#execute ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/jaxx/download.rb', line 24 def execute process.start do |storage| directory = storage.directories.get(process.bucket) files(directory).each do |target, source| File.open(target, 'wb') do |file| directory.files.get(source) {|chunk, byt_remain, byt_total| file.write(chunk) } end end end end |
#files(directory) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jaxx/download.rb', line 12 def files directory if process.file.match(%r{/$}) directory.files.inject({}) do |hsh, f| key = f.key.gsub(process.file, '') hsh[key] = f.key if !key.empty? and f.key.match(process.file) hsh end else { File.basename(process.file) => process.file } end end |