Class: Cheetah::FileDownloader

Inherits:
Object
  • Object
show all
Defined in:
lib/cheetah/services/file_downloader.rb

Constant Summary collapse

CANCELED_FOLDER_NAME =
'canceladas'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(invoice) ⇒ FileDownloader

Returns a new instance of FileDownloader.



7
8
9
# File 'lib/cheetah/services/file_downloader.rb', line 7

def initialize(invoice)
  @invoice = invoice
end

Instance Attribute Details

#invoiceObject (readonly)

Returns the value of attribute invoice.



3
4
5
# File 'lib/cheetah/services/file_downloader.rb', line 3

def invoice
  @invoice
end

Class Method Details

.download!(invoice) ⇒ Object



11
12
13
# File 'lib/cheetah/services/file_downloader.rb', line 11

def self.download!(invoice)
  new(invoice).download!
end

Instance Method Details

#download!Object



15
16
17
18
19
# File 'lib/cheetah/services/file_downloader.rb', line 15

def download!
  File.open("#{directory}/#{invoice.number}.xml", 'wb') do |file|
    file.write(open(invoice.s3_path).read)
  end
end