Class: Cnab240::Lote
- Inherits:
-
Object
- Object
- Cnab240::Lote
- Defined in:
- lib/cnab240/arquivo/lote.rb
Instance Attribute Summary collapse
-
#arquivo ⇒ Object
Returns the value of attribute arquivo.
-
#header ⇒ Object
Returns the value of attribute header.
-
#operacao ⇒ Object
Returns the value of attribute operacao.
-
#segmentos ⇒ Object
Returns the value of attribute segmentos.
-
#tipo ⇒ Object
Returns the value of attribute tipo.
-
#trailer ⇒ Object
Returns the value of attribute trailer.
Instance Method Summary collapse
- #<<(s) ⇒ Object
- #auto_fill ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Lote
constructor
A new instance of Lote.
- #linhas ⇒ Object
- #read_segmento(s, line) ⇒ Object
- #string ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Lote
Returns a new instance of Lote.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cnab240/arquivo/lote.rb', line 11 def initialize( = {}) @segmentos = [] @operacao ||= [:operacao] @tipo ||= [:tipo] @versao ||= [:versao] @fallback ||= [:fallback] @versao ||= 'V86' raise "Operacao nao suportada: #{operacao}" if ESTRUTURA[@versao][operacao].nil? estrutura = ESTRUTURA[@versao][operacao] @header = estrutura[:header].new @trailer = estrutura[:trailer].new yield self if block_given? end |
Instance Attribute Details
#arquivo ⇒ Object
Returns the value of attribute arquivo.
9 10 11 |
# File 'lib/cnab240/arquivo/lote.rb', line 9 def arquivo @arquivo end |
#header ⇒ Object
Returns the value of attribute header.
4 5 6 |
# File 'lib/cnab240/arquivo/lote.rb', line 4 def header @header end |
#operacao ⇒ Object
Returns the value of attribute operacao.
7 8 9 |
# File 'lib/cnab240/arquivo/lote.rb', line 7 def operacao @operacao end |
#segmentos ⇒ Object
Returns the value of attribute segmentos.
5 6 7 |
# File 'lib/cnab240/arquivo/lote.rb', line 5 def segmentos @segmentos end |
#tipo ⇒ Object
Returns the value of attribute tipo.
8 9 10 |
# File 'lib/cnab240/arquivo/lote.rb', line 8 def tipo @tipo end |
#trailer ⇒ Object
Returns the value of attribute trailer.
6 7 8 |
# File 'lib/cnab240/arquivo/lote.rb', line 6 def trailer @trailer end |
Instance Method Details
#<<(s) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cnab240/arquivo/lote.rb', line 36 def <<(s) versao = arquivo.versao unless arquivo.nil? versao ||= @versao case s when Symbol, String segmentos << seg = eval("Cnab240::#{versao}::Segmento#{s.to_s.upcase}.new") else segmentos << seg = s end seg.lote = self seg end |
#auto_fill ⇒ Object
65 66 67 68 |
# File 'lib/cnab240/arquivo/lote.rb', line 65 def auto_fill # totais_qtde_registros end |
#linhas ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cnab240/arquivo/lote.rb', line 49 def linhas self.auto_fill if Cnab240.auto_fill_enabled seg_array = [] estrutura = ESTRUTURA[@versao][operacao] seg_array << @header.linha segmentos.each do |s| seg_array << s.linha end seg_array << @trailer.linha seg_array end |
#read_segmento(s, line) ⇒ Object
30 31 32 33 34 |
# File 'lib/cnab240/arquivo/lote.rb', line 30 def read_segmento(s, line) versao = arquivo.versao unless arquivo.nil? versao ||= @versao segmentos << seg = eval("Cnab240::#{versao}::Segmento#{s.to_s.upcase}.read(line)") end |
#string ⇒ Object
61 62 63 |
# File 'lib/cnab240/arquivo/lote.rb', line 61 def string linhas.join("\r\n") end |