Class: BAI2::Group
- Inherits:
-
Object
- Object
- BAI2::Group
- Defined in:
- lib/bai2_ruby/group.rb
Instance Attribute Summary collapse
-
#accounts ⇒ Object
readonly
Returns the value of attribute accounts.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#trailer ⇒ Object
readonly
Returns the value of attribute trailer.
Instance Method Summary collapse
-
#initialize(header, accounts, trailer = nil) ⇒ Group
constructor
A new instance of Group.
- #net_total ⇒ Object
- #set_trailer(trailer) ⇒ Object
- #total_credits ⇒ Object
- #total_debits ⇒ Object
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
#accounts ⇒ Object (readonly)
Returns the value of attribute accounts.
5 6 7 |
# File 'lib/bai2_ruby/group.rb', line 5 def accounts @accounts end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
5 6 7 |
# File 'lib/bai2_ruby/group.rb', line 5 def header @header end |
#trailer ⇒ Object (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_total ⇒ Object
27 28 29 |
# File 'lib/bai2_ruby/group.rb', line 27 def net_total accounts.sum(&:net_total) end |
#set_trailer(trailer) ⇒ Object
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_credits ⇒ Object
19 20 21 |
# File 'lib/bai2_ruby/group.rb', line 19 def total_credits accounts.sum(&:total_credits) end |
#total_debits ⇒ Object
23 24 25 |
# File 'lib/bai2_ruby/group.rb', line 23 def total_debits accounts.sum(&:total_debits) end |