Class: Xirr::Transaction

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

Overview

A unit of the Cashflow.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount, opts = {}) ⇒ Transaction

Note:

Don’t forget to add date: [Date] in the opts hash.

Returns a new instance of Transaction.

Examples:

Transaction.new -1000, date: Date.now

Parameters:

  • amount (Numeric)
  • opts (Hash) (defaults to: {})


13
14
15
16
17
18
19
20
# File 'lib/xirr/transaction.rb', line 13

def initialize(amount, opts = {})
  self.amount = amount

  # Set optional attributes..
  opts.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



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

def amount
  @amount
end

#dateObject

Returns the value of attribute date.



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

def date
  @date
end

Instance Method Details

#inspectString

Returns:

  • (String)


37
38
39
# File 'lib/xirr/transaction.rb', line 37

def inspect
  "T(#{@amount},#{@date})"
end