class Xirr::Transaction

A unit of the Cashflow.

Attributes

amount[R]
date[R]

Public Class Methods

new(amount, opts={}) click to toggle source

@example

Transaction.new -1000, date: Date.now

@param amount [Numeric] @param opts [Hash] @note Don't forget to add date: [Date] in the opts hash.

# File lib/xirr/transaction.rb, line 12
def initialize(amount, opts={})
  self.amount = amount

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

Public Instance Methods

amount=(value) click to toggle source

Sets the amount @param value [Numeric] @return [Float]

# File lib/xirr/transaction.rb, line 31
def amount=(value)
  @amount = value.to_f || 0.0
end
date=(value) click to toggle source

Sets the date @param value [Date, Time] @return [Date]

# File lib/xirr/transaction.rb, line 24
def date=(value)
  @date = value.kind_of?(Time) ? value.to_date : value
end
inspect() click to toggle source

@return [String]

# File lib/xirr/transaction.rb, line 36
def inspect
  "T(#{@amount},#{@date})"
end