I'm trying to get the date to be my hash's key and then have the total of the balance be the value in my hash array to use the hash later when returning an account statement which will print date, amount and balance.
Here is the code:
class Bank
attr_accessor :total, :time
def initialize
@total = 0
@time = [:date => @total]
end
def deposit(sum)
@total += sum
end
def withdrawl(sum)
@total -= sum
end
def input_time
@time << Time.now.strftime('%d/%-m/%Y')
end
def yesterday
@time << Time.at(Time.now.to_i - 86400).strftime('%d/%-m/%Y')
end
end
How would I get the date to be the hash key? I'm currently trying to append it in but that's just adding to the array.