Class: Financier::Transaction
- Inherits:
-
Object
- Object
- Financier::Transaction
- Defined in:
- lib/financier/transaction.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
- #after?(other_date) ⇒ Boolean
- #before?(other_date) ⇒ Boolean
- #credit? ⇒ Boolean
- #debit? ⇒ Boolean
-
#initialize(amount, date = Date[Time.now]) ⇒ Transaction
constructor
A new instance of Transaction.
- #on?(other_date) ⇒ Boolean
- #to_s ⇒ Object
- #zero? ⇒ Boolean
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
#amount ⇒ Object
Returns the value of attribute amount.
3 4 5 |
# File 'lib/financier/transaction.rb', line 3 def amount @amount end |
#date ⇒ Object
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
31 32 33 |
# File 'lib/financier/transaction.rb', line 31 def after?(other_date) date > other_date.to_date end |
#before?(other_date) ⇒ Boolean
27 28 29 |
# File 'lib/financier/transaction.rb', line 27 def before?(other_date) date < other_date.to_date end |
#credit? ⇒ Boolean
15 16 17 |
# File 'lib/financier/transaction.rb', line 15 def credit? amount.positive? end |
#debit? ⇒ Boolean
35 36 37 |
# File 'lib/financier/transaction.rb', line 35 def debit? amount.negative? end |
#on?(other_date) ⇒ Boolean
23 24 25 |
# File 'lib/financier/transaction.rb', line 23 def on?(other_date) date === other_date.to_date end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/financier/transaction.rb', line 43 def to_s amount.to_s end |
#zero? ⇒ Boolean
39 40 41 |
# File 'lib/financier/transaction.rb', line 39 def zero? amount.zero? end |