Class: Transaction
- Inherits:
-
Object
- Object
- Transaction
- Defined in:
- lib/transaction.rb
Overview
Transaction A single transaction
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#creditor ⇒ Object
readonly
Returns the value of attribute creditor.
-
#debtor ⇒ Object
readonly
Returns the value of attribute debtor.
Instance Method Summary collapse
- #==(obj) ⇒ Object
-
#initialize(debtor, creditor, amount) ⇒ Transaction
constructor
A new instance of Transaction.
-
#reverse ⇒ Object
Returns a transaction that is the reverse of the current one.
Constructor Details
#initialize(debtor, creditor, amount) ⇒ Transaction
Returns a new instance of Transaction.
8 9 10 11 12 |
# File 'lib/transaction.rb', line 8 def initialize(debtor, creditor, amount) @debtor = debtor @creditor = creditor @amount = amount end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
6 7 8 |
# File 'lib/transaction.rb', line 6 def amount @amount end |
#creditor ⇒ Object (readonly)
Returns the value of attribute creditor.
6 7 8 |
# File 'lib/transaction.rb', line 6 def creditor @creditor end |
#debtor ⇒ Object (readonly)
Returns the value of attribute debtor.
6 7 8 |
# File 'lib/transaction.rb', line 6 def debtor @debtor end |
Instance Method Details
#==(obj) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/transaction.rb', line 19 def ==(obj) ( obj.amount == self.amount && obj.creditor == self.creditor && obj.debtor == self.debtor ) end |
#reverse ⇒ Object
Returns a transaction that is the reverse of the current one
15 16 17 |
# File 'lib/transaction.rb', line 15 def reverse Transaction.new(@creditor, @debtor, @amount) end |