Class: Ldgr::Transaction

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Transaction

Returns a new instance of Transaction.

Yields:

  • (_self)

Yield Parameters:



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

def initialize(&block)
  yield self if block_given?
end

Instance Attribute Details

#accountObject

Returns the value of attribute account.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def 
  @account
end

#amountObject

Returns the value of attribute amount.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def amount
  @amount
end

#clearedObject

Returns the value of attribute cleared.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def cleared
  @cleared
end

#currencyObject

Returns the value of attribute currency.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def currency
  @currency
end

#dateObject

Returns the value of attribute date.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def date
  @date
end

#effectiveObject

Returns the value of attribute effective.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def effective
  @effective
end

#equityObject

Returns the value of attribute equity.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def equity
  @equity
end

#payeeObject

Returns the value of attribute payee.



16
17
18
# File 'lib/ldgr/transaction.rb', line 16

def payee
  @payee
end

Instance Method Details

#to_sObject



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

Returns:

  • (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().empty?
  true
end