Class: BAI2::File
- Inherits:
-
Object
- Object
- BAI2::File
- Defined in:
- lib/bai2_ruby/file.rb
Instance Attribute Summary collapse
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#trailer ⇒ Object
readonly
Returns the value of attribute trailer.
Instance Method Summary collapse
- #all_transactions ⇒ Object
-
#initialize(header, groups, trailer) ⇒ File
constructor
A new instance of File.
- #net_total ⇒ Object
- #total_credits ⇒ Object
- #total_debits ⇒ Object
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
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
5 6 7 |
# File 'lib/bai2_ruby/file.rb', line 5 def groups @groups end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
5 6 7 |
# File 'lib/bai2_ruby/file.rb', line 5 def header @header end |
#trailer ⇒ Object (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_transactions ⇒ Object
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_total ⇒ Object
21 22 23 |
# File 'lib/bai2_ruby/file.rb', line 21 def net_total groups.sum(&:net_total) end |
#total_credits ⇒ Object
13 14 15 |
# File 'lib/bai2_ruby/file.rb', line 13 def total_credits groups.sum(&:total_credits) end |
#total_debits ⇒ Object
17 18 19 |
# File 'lib/bai2_ruby/file.rb', line 17 def total_debits groups.sum(&:total_debits) end |