Class: BAI2::File

Inherits:
Object
  • Object
show all
Defined in:
lib/bai2_ruby/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, groups, trailer) ⇒ File

Returns a new instance of File.



7
8
9
10
11
# File 'lib/bai2_ruby/file.rb', line 7

def initialize(header, groups, trailer)
  @header = header
  @groups = groups
  @trailer = trailer
end

Instance Attribute Details

#groupsObject (readonly)

Returns the value of attribute groups.



5
6
7
# File 'lib/bai2_ruby/file.rb', line 5

def groups
  @groups
end

#headerObject (readonly)

Returns the value of attribute header.



5
6
7
# File 'lib/bai2_ruby/file.rb', line 5

def header
  @header
end

#trailerObject (readonly)

Returns the value of attribute trailer.



5
6
7
# File 'lib/bai2_ruby/file.rb', line 5

def trailer
  @trailer
end

Instance Method Details

#all_transactionsObject



25
26
27
# File 'lib/bai2_ruby/file.rb', line 25

def all_transactions
  groups.flat_map { |group| group.accounts.flat_map(&:transactions) }
end

#net_totalObject



21
22
23
# File 'lib/bai2_ruby/file.rb', line 21

def net_total
  groups.sum(&:net_total)
end

#total_creditsObject



13
14
15
# File 'lib/bai2_ruby/file.rb', line 13

def total_credits
  groups.sum(&:total_credits)
end

#total_debitsObject



17
18
19
# File 'lib/bai2_ruby/file.rb', line 17

def total_debits
  groups.sum(&:total_debits)
end