Class: Ldgr::Transaction
- Inherits:
-
Object
- Object
- Ldgr::Transaction
- Defined in:
- lib/ldgr/transaction.rb
Overview
Builds a transaction
Examples
Transaction.new do |t|
t.payee = "Something"
t.amount = 1000
t.date = Date.today + 1
end
# => <class Transaction @payee="Something", @amount=1000, @date=Date.today + 1>
Returns a transaction.
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#cleared ⇒ Object
Returns the value of attribute cleared.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#date ⇒ Object
Returns the value of attribute date.
-
#effective ⇒ Object
Returns the value of attribute effective.
-
#equity ⇒ Object
Returns the value of attribute equity.
-
#payee ⇒ Object
Returns the value of attribute payee.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Transaction
constructor
A new instance of Transaction.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize {|_self| ... } ⇒ Transaction
Returns a new instance of Transaction.
18 19 20 |
# File 'lib/ldgr/transaction.rb', line 18 def initialize(&block) yield self if block_given? end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def account @account end |
#amount ⇒ Object
Returns the value of attribute amount.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def amount @amount end |
#cleared ⇒ Object
Returns the value of attribute cleared.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def cleared @cleared end |
#currency ⇒ Object
Returns the value of attribute currency.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def currency @currency end |
#date ⇒ Object
Returns the value of attribute date.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def date @date end |
#effective ⇒ Object
Returns the value of attribute effective.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def effective @effective end |
#equity ⇒ Object
Returns the value of attribute equity.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def equity @equity end |
#payee ⇒ Object
Returns the value of attribute payee.
16 17 18 |
# File 'lib/ldgr/transaction.rb', line 16 def payee @payee end |
Instance Method Details
#to_s ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/ldgr/transaction.rb', line 22 def to_s " \#{date} \#{cleared}\#{payee}\n \#{account} \#{currency}\#{amount}\n \#{equity}\n HERE\nend\n" |
#valid? ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/ldgr/transaction.rb', line 30 def valid? return false if String(payee).empty? return false if String(amount).empty? return false if String(account).empty? true end |