Class: Bankscrap::Transaction
- Inherits:
-
Object
- Object
- Bankscrap::Transaction
- Includes:
- Utils::Inspectable
- Defined in:
- lib/bankscrap/transaction.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#balance ⇒ Object
Returns the value of attribute balance.
-
#description ⇒ Object
Returns the value of attribute description.
-
#effective_date ⇒ Object
Returns the value of attribute effective_date.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #currency ⇒ Object
-
#initialize(params = {}) ⇒ Transaction
constructor
A new instance of Transaction.
- #to_a ⇒ Object
- #to_s ⇒ Object
Methods included from Utils::Inspectable
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
#account ⇒ Object
Returns the value of attribute account.
5 6 7 |
# File 'lib/bankscrap/transaction.rb', line 5 def account @account end |
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/bankscrap/transaction.rb', line 5 def amount @amount end |
#balance ⇒ Object
Returns the value of attribute balance.
5 6 7 |
# File 'lib/bankscrap/transaction.rb', line 5 def balance @balance end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/bankscrap/transaction.rb', line 5 def description @description end |
#effective_date ⇒ Object
Returns the value of attribute effective_date.
5 6 7 |
# File 'lib/bankscrap/transaction.rb', line 5 def effective_date @effective_date end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/bankscrap/transaction.rb', line 5 def id @id end |
Instance Method Details
#currency ⇒ Object
22 23 24 |
# File 'lib/bankscrap/transaction.rb', line 22 def currency amount.currency end |
#to_a ⇒ Object
18 19 20 |
# File 'lib/bankscrap/transaction.rb', line 18 def to_a [effective_date.strftime('%d/%m/%Y'), description, amount] end |
#to_s ⇒ Object
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 |