Method: Finance::Transaction#initialize

Defined in:
lib/finance/transaction.rb

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

create a new Transaction

Examples:

a simple transaction

t = Transaction.new(400)

a transaction with a period number

t = Transaction.new(400, :period => 3)

Parameters:

  • amount (Numeric)

    the cash value of the transaction

  • opts (optional, Hash) (defaults to: {})

    sets optional attributes

Options Hash (opts):

  • :period (String)

    the period number of the transaction



51
52
53
54
55
56
57
58
59
# File 'lib/finance/transaction.rb', line 51

def initialize(amount, opts={})
  @amount = amount
  @original = amount

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