Class: LeccaClient::Downloader
- Inherits:
-
Object
- Object
- LeccaClient::Downloader
- Defined in:
- lib/lecca_client/downloader.rb
Instance Method Summary collapse
Instance Method Details
#download_file(filename) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/lecca_client/downloader.rb', line 5 def download_file(filename) file = {} Net::SFTP.start(config[:host], config[:user], password: config[:pass]) do |sftp| file = { filename: filename, filepath: download_path(filename), content: sftp.download!(download_path(filename)) } end file end |
#download_files(prefix = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/lecca_client/downloader.rb', line 19 def download_files(prefix = nil) files = [] Net::SFTP.start(config[:host], config[:user], password: config[:pass]) do |sftp| sftp.dir.foreach(download_path) do |entry| next if !entry.file? || (prefix.present? && !entry.name.include?(prefix)) files << { filename: entry.name, filepath: download_path(entry.name), content: sftp.download!(download_path(entry.name)) } end end files end |