Class: Financier::Transaction

Inherits:
Object
  • Object
show all
Defined in:
lib/financier/transaction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount, date = Date[Time.now]) ⇒ Transaction

Returns a new instance of Transaction.



6
7
8
9
# File 'lib/financier/transaction.rb', line 6

def initialize(amount, date = Date[Time.now])
  send(:amount=, amount)
  send(:date=, date)
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/financier/transaction.rb', line 3

def amount
  @amount
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/financier/transaction.rb', line 4

def date
  @date
end

Instance Method Details

#after?(other_date) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/financier/transaction.rb', line 31

def after?(other_date)
  date > other_date.to_date
end

#before?(other_date) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/financier/transaction.rb', line 27

def before?(other_date)
  date < other_date.to_date
end

#credit?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/financier/transaction.rb', line 15

def credit?
  amount.positive?
end

#debit?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/financier/transaction.rb', line 35

def debit?
  amount.negative?
end

#on?(other_date) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/financier/transaction.rb', line 23

def on?(other_date)
  date === other_date.to_date
end

#to_sObject



43
44
45
# File 'lib/financier/transaction.rb', line 43

def to_s
  amount.to_s
end

#zero?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/financier/transaction.rb', line 39

def zero?
  amount.zero?
end