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.



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

def initialize(params = {})
  raise NotMoneyObjectError, :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

#description_detailObject

Returns the value of attribute description_detail.



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

def description_detail
  @description_detail
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

#operation_dateObject

Returns the value of attribute operation_date.



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

def operation_date
  @operation_date
end

Instance Method Details

#currencyObject



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

def currency
  amount.currency
end

#to_aObject



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

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

#to_sObject



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

def to_s
  description
end