Skip to content

Commit

Permalink
add FooterFormatter to pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shouichi committed Sep 2, 2013
1 parent aeb6d62 commit 4ec9eb4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/zengin/formatters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,25 @@ def format
[2, deposit[:bank_code], nil, deposit[:branch_code], nil, nil, deposit[:account_type], deposit[:account_number], deposit[:account_name], deposit[:amount], 0, nil]
end
end

class FooterFormatter
attr_accessor :deposits

def initialize(deposits)
self.deposits = deposits
end

def format
[[8, deposits.length, sum, nil, nil, nil, nil, nil, nil, nil, nil, nil],
[9, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]]
end

private

def sum
deposits.reduce(0) do |accumulator, deposit|
accumulator + deposit[:amount]
end
end
end
end

0 comments on commit 4ec9eb4

Please sign in to comment.