Class: RubyCnab240::Arquivo::Lote::Trailer

Inherits:
RubyCnab240::Arquivo::Lote show all
Defined in:
lib/rubycnab240/arquivo/lotes/trailer.rb

Instance Attribute Summary collapse

Attributes inherited from RubyCnab240::Arquivo::Lote

#lot_header, #lot_trailer, #lots

Attributes inherited from RubyCnab240::Arquivo

#data_dos_pagamentos, #header, #lot_header, #lot_trailer, #segments, #trailer

Instance Method Summary collapse

Methods inherited from RubyCnab240::Arquivo::Lote

#<<

Methods inherited from RubyCnab240::Arquivo

#<<, #number_of_segments, #save_to_file

Constructor Details

#initialize(fields = {}) ⇒ Trailer

Returns a new instance of Trailer.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 15

def initialize(fields = {})

  @codigo_do_banco_na_compensacao = fields[:codigo_do_banco_na_compensacao].to_s[0..2].rjust(3, '0') #default: 001
  @lote_do_servico = fields[:lote_do_servico].to_s[0..3].rjust(4, '0')
  @tipo_de_registro = fields[:tipo_de_registro].to_s[0..0].rjust(1, '0')
  @uso_exclusivo_febraban = ' ' * 9
  @qtd_registros_de_lote = fields[:qtd_registros_de_lote].to_s[0..5].rjust(6, '0')
  @somatorio_dos_valores = fields[:somatorio_dos_valores].to_s[0..17].rjust(18, '0')
  @somatorio_qtd_de_moedas = ' ' * 18
  @numero_de_aviso_debito = ' ' * 6
  @uso_exclusivo_febraban2 = ' ' * 165
  @codigo_das_ocorrencias_para_retorno = ' ' * 10
end

Instance Attribute Details

#codigo_das_ocorrencias_para_retornoObject (readonly)

Returns the value of attribute codigo_das_ocorrencias_para_retorno.



12
13
14
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 12

def codigo_das_ocorrencias_para_retorno
  @codigo_das_ocorrencias_para_retorno
end

#codigo_do_banco_na_compensacaoObject

Returns the value of attribute codigo_do_banco_na_compensacao.



2
3
4
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 2

def codigo_do_banco_na_compensacao
  @codigo_do_banco_na_compensacao
end

#lote_do_servicoObject

Returns the value of attribute lote_do_servico.



3
4
5
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 3

def lote_do_servico
  @lote_do_servico
end

#numero_de_aviso_debitoObject (readonly)

Returns the value of attribute numero_de_aviso_debito.



10
11
12
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 10

def numero_de_aviso_debito
  @numero_de_aviso_debito
end

#qtd_registros_de_loteObject

Returns the value of attribute qtd_registros_de_lote.



4
5
6
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 4

def qtd_registros_de_lote
  @qtd_registros_de_lote
end

#somatorio_dos_valoresObject

Returns the value of attribute somatorio_dos_valores.



5
6
7
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 5

def somatorio_dos_valores
  @somatorio_dos_valores
end

#somatorio_qtd_de_moedasObject (readonly)

Returns the value of attribute somatorio_qtd_de_moedas.



9
10
11
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 9

def somatorio_qtd_de_moedas
  @somatorio_qtd_de_moedas
end

#tipo_de_registroObject (readonly)

Returns the value of attribute tipo_de_registro.



7
8
9
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 7

def tipo_de_registro
  @tipo_de_registro
end

#uso_exclusivo_febrabanObject (readonly)

Returns the value of attribute uso_exclusivo_febraban.



8
9
10
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 8

def uso_exclusivo_febraban
  @uso_exclusivo_febraban
end

#uso_exclusivo_febraban2Object (readonly)

Returns the value of attribute uso_exclusivo_febraban2.



11
12
13
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 11

def uso_exclusivo_febraban2
  @uso_exclusivo_febraban2
end

Instance Method Details

#to_stringObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rubycnab240/arquivo/lotes/trailer.rb', line 29

def to_string
  trailer = String.new

  trailer << self.codigo_do_banco_na_compensacao
  trailer << self.lote_do_servico
  trailer << self.tipo_de_registro
  trailer << self.uso_exclusivo_febraban
  trailer << self.qtd_registros_de_lote
  trailer << self.somatorio_dos_valores
  trailer << self.somatorio_qtd_de_moedas
  trailer << self.numero_de_aviso_debito
  trailer << self.uso_exclusivo_febraban2
  trailer << self.codigo_das_ocorrencias_para_retorno
end