Class: Codabel::Record::Trailer

Inherits:
Codabel::Record show all
Defined in:
lib/codabel/record/trailer.rb

Constant Summary collapse

FOLLOWING =
{ when_true: '1', when_false: '2' }.freeze

Instance Attribute Summary

Attributes inherited from Codabel::Record

#data

Instance Method Summary collapse

Methods inherited from Codabel::Record

#actual_records, add_column, column, columns, for, header, #initialize, movement, movement21, movement22, movement23, new_balance, old_balance, required?, #to_coda, trailer

Constructor Details

This class inherits a constructor from Codabel::Record

Instance Method Details

#auto_enrich(file) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/codabel/record/trailer.rb', line 14

def auto_enrich(file)
  enriched = data.merge(
    records_count: data[:records_count] || count_records(file),
    debit: data[:debit] || sum_debit(file),
    credit: data[:credit] || sum_credit(file)
  )
  Trailer.new(enriched)
end

#validate!(file) ⇒ Object



23
24
25
26
27
# File 'lib/codabel/record/trailer.rb', line 23

def validate!(file)
  validate_records_count!(file)
  validate_credit!(file)
  validate_debit!(file)
end