Class: LeccaClient::CNAB::Loan::LoanFile

Inherits:
Object
  • Object
show all
Defined in:
lib/lecca_client/cnab/loan/loan_file.rb

Constant Summary collapse

FILE_PREFIX =
'LEC_DEPARA'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename:, filepath:, content:) ⇒ LoanFile



8
9
10
11
12
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 8

def initialize(filename:, filepath:, content:)
  @filename = filename
  @filepath = filepath
  @content = content
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 6

def content
  @content
end

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 6

def filename
  @filename
end

#filepathObject (readonly)

Returns the value of attribute filepath.



6
7
8
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 6

def filepath
  @filepath
end

Class Method Details

.available_filesObject



26
27
28
29
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 26

def self.available_files
  files = LeccaClient::Downloader.new.download_files(FILE_PREFIX)
  files.map { |file| new(file) }
end

.retrieve_file(filename) ⇒ Object



22
23
24
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 22

def self.retrieve_file(filename)
  new(LeccaClient::Downloader.new.download_file(filename))
end

Instance Method Details

#parseObject



14
15
16
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 14

def parse
  @parsed ||= Parser.new(content).parse
end

#purgeObject



18
19
20
# File 'lib/lecca_client/cnab/loan/loan_file.rb', line 18

def purge
  LeccaClient::FileHandler.new.remove(filepath)
end