Class: Bankscrap::Transaction

Inherits:
Object
  • Object
show all
Includes:
Utils::Inspectable
Defined in:
lib/bankscrap/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Inspectable

#inspect

Constructor Details

#initialize(params = {}) ⇒ Transaction

Returns a new instance of Transaction.



8
9
10
11
12
# File 'lib/bankscrap/transaction.rb', line 8

def initialize(params = {})
  raise NotMoneyObjectError.new(:amount) unless params[:amount].is_a?(Money)

  params.each { |key, value| send "#{key}=", value }
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



5
6
7
# File 'lib/bankscrap/transaction.rb', line 5

def 
  @account
end

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/bankscrap/transaction.rb', line 5

def amount
  @amount
end

#balanceObject

Returns the value of attribute balance.



5
6
7
# File 'lib/bankscrap/transaction.rb', line 5

def balance
  @balance
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/bankscrap/transaction.rb', line 5

def description
  @description
end

#effective_dateObject

Returns the value of attribute effective_date.



5
6
7
# File 'lib/bankscrap/transaction.rb', line 5

def effective_date
  @effective_date
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/bankscrap/transaction.rb', line 5

def id
  @id
end

Instance Method Details

#currencyObject



22
23
24
# File 'lib/bankscrap/transaction.rb', line 22

def currency
  amount.currency
end

#to_aObject



18
19
20
# File 'lib/bankscrap/transaction.rb', line 18

def to_a
  [effective_date.strftime('%d/%m/%Y'), description, amount]
end

#to_sObject



14
15
16
# File 'lib/bankscrap/transaction.rb', line 14

def to_s
  "#{effective_date.strftime('%d/%m/%Y')}   #{description.ljust(45)} #{amount.format.rjust(20)}"
end