class Headache::Record::FileControl

Attributes

document[RW]

Public Class Methods

new(document = nil) click to toggle source
# File lib/headache/record/file_control.rb, line 8
def initialize(document = nil)
  @document = document
end

Public Instance Methods

batch_count() click to toggle source
# File lib/headache/record/file_control.rb, line 12
def batch_count
  document.batches.count
end
block_count() click to toggle source
# File lib/headache/record/file_control.rb, line 16
def block_count
  (((batch_count * 2) + document.entries.count + 2) / 10.0).ceil
end
entry_count() click to toggle source
# File lib/headache/record/file_control.rb, line 20
def entry_count
  document.entries.count
end
entry_hash() click to toggle source
# File lib/headache/record/file_control.rb, line 24
def entry_hash
  batch_sum(:entry_hash).to_s.last(10)
end
total_credit() click to toggle source
# File lib/headache/record/file_control.rb, line 32
def total_credit
  batch_sum :total_credit
end
total_debit() click to toggle source
# File lib/headache/record/file_control.rb, line 28
def total_debit
  batch_sum :total_debit
end

Protected Instance Methods

batch_sum(method) click to toggle source
# File lib/headache/record/file_control.rb, line 38
def batch_sum(method)
  document.batches
    .map { |b| b.send method }
    .map(&:to_i).sum
end