Module: Cnab
- Defined in:
- lib/cnab.rb,
lib/cnab/helper.rb,
lib/cnab/detalhe.rb,
lib/cnab/retorno.rb,
lib/cnab/version.rb,
lib/cnab/definition.rb,
lib/cnab/exceptions.rb,
lib/cnab/definitions.rb,
lib/cnab/header_lote.rb,
lib/cnab/trailer_lote.rb,
lib/cnab/header_arquivo.rb,
lib/cnab/trailer_arquivo.rb,
lib/cnab/definitions/helper.rb,
lib/cnab/detalhe/segmento_t.rb,
lib/cnab/detalhe/segmento_u.rb,
lib/cnab/detalhe/segmento_t_u.rb,
lib/cnab/header_lote/cobranca.rb,
lib/cnab/trailer_lote/cobranca.rb,
lib/cnab/definitions/segmento_t.rb,
lib/cnab/definitions/segmento_u.rb,
lib/cnab/definitions/header_lote.rb,
lib/cnab/definitions/trailer_lote.rb,
lib/cnab/exceptions/no_file_given.rb,
lib/cnab/definitions/header_arquivo.rb,
lib/cnab/definitions/trailer_arquivo.rb,
lib/cnab/exceptions/line_not_parseable.rb,
lib/cnab/exceptions/segment_not_implemented.rb,
lib/cnab/exceptions/version_not_implemented.rb
Defined Under Namespace
Modules: Definitions, Detalhe, Exceptions, HeaderLote, Helper, TrailerLote
Classes: Definition, HeaderArquivo, Retorno, TrailerArquivo
Constant Summary
collapse
- VERSION =
"0.4.3"
Class Method Summary
collapse
Class Method Details
.lib_path ⇒ Object
52
53
54
|
# File 'lib/cnab.rb', line 52
def self.lib_path
File.join(root_path, 'lib')
end
|
.parse(file = nil, merge = false, version = '08.7') ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cnab.rb', line 17
def self.parse(file = nil, merge = false, version = '08.7')
raise Exceptions::NoFileGiven if file.nil?
definition = Cnab::Definition.new(version)
File.open(file, 'rb') do |f|
= HeaderArquivo.new(f.gets, definition.)
= HeaderLote::Cobranca.new(f.gets, definition.)
detalhes = []
while(line = f.gets)
if line[7] == "5"
trailer_lote = TrailerLote::Cobranca.new(line, definition.trailer_lote)
break
end
if merge
detalhes << Detalhe.merge(line, f.gets, definition)
else
detalhes << Detalhe.parse(line, definition)
end
end
trailer_arquivo = TrailerArquivo.new(f.gets, definition.trailer_arquivo)
Retorno.new({ :header_arquivo => ,
:header_lote => ,
:detalhes => detalhes,
:trailer_lote => trailer_lote,
:trailer_arquivo => trailer_arquivo })
end
end
|
.root_path ⇒ Object
48
49
50
|
# File 'lib/cnab.rb', line 48
def self.root_path
File.expand_path(File.join(File.dirname(__FILE__), '..'))
end
|