From fa20f3c7c47c860718f4ca63c06953efbab02960 Mon Sep 17 00:00:00 2001 From: Annalee Date: Tue, 13 Oct 2015 18:23:55 -0700 Subject: [PATCH] Modified Wave 2- wrote self.find and self.all methods --- bank_account_wave2a.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bank_account_wave2a.rb b/bank_account_wave2a.rb index 34a0df8d..04d36c09 100644 --- a/bank_account_wave2a.rb +++ b/bank_account_wave2a.rb @@ -1,4 +1,5 @@ require 'csv' +require 'pry' module Bank class Account @@ -40,16 +41,24 @@ def deposit (deposit_amount) def self.all #returns a collection of Account instances representing all of the Accounts in CSV account_csv = CSV.read("./support/accounts.csv") - account_array= [] + account_array= [] account_csv.each do |row| - account =Bank::Account.new(row[0],row[1].to_i,row[2]) - account_array.push(account) - end + account =Bank::Account.new(row[0],row[1].to_i,row[2]) + account_array.push(account) + end + return account_array end def self.find(id) - self.find_all {|account| account.id == id} + all_accounts = Account.all + all_accounts.each do |account| + if id == account.id + return account + end + end + end + end end