Class: BAI2::Group

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, accounts, trailer = nil) ⇒ Group

Returns a new instance of Group.



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

def initialize(header, accounts, trailer = nil)
  @header = header
  @accounts = accounts
  @trailer = trailer
end

Instance Attribute Details

#accountsObject (readonly)

Returns the value of attribute accounts.



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

def accounts
  @accounts
end

#headerObject (readonly)

Returns the value of attribute header.



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

def header
  @header
end

#trailerObject (readonly)

Returns the value of attribute trailer.



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

def trailer
  @trailer
end

Instance Method Details

#net_totalObject



27
28
29
# File 'lib/bai2_ruby/group.rb', line 27

def net_total
  accounts.sum(&:net_total)
end

#set_trailer(trailer) ⇒ Object

Raises:



13
14
15
16
17
# File 'lib/bai2_ruby/group.rb', line 13

def set_trailer(trailer)
  raise BAI2::Error, "Trailer has already been set" if @trailer

  @trailer = trailer
end

#total_creditsObject



19
20
21
# File 'lib/bai2_ruby/group.rb', line 19

def total_credits
  accounts.sum(&:total_credits)
end

#total_debitsObject



23
24
25
# File 'lib/bai2_ruby/group.rb', line 23

def total_debits
  accounts.sum(&:total_debits)
end