lib/xirr/transaction.rb in xirr-0.1.0 vs lib/xirr/transaction.rb in xirr-0.1.1

- old
+ new

@@ -1,42 +1,32 @@ module Xirr + # A unit of the Cashflow. class Transaction attr_reader :amount attr_accessor :date + # @example + # Transaction.new -1000, date: Time.now def initialize(amount, opts={}) @amount = amount - @original = amount # Set optional attributes.. opts.each do |key, value| send("#{key}=", value) end end + # Sets the amount + # @param value [Float, Integer] + # @return [Float] def amount=(value) @amount = value.to_f || 0 end + # @return [String] def inspect "T(#{@amount},#{@date})" - end - - def description - investment ? "#{self.investment.transaction_type_name}: #{round.description}" : @description - end - - def round - @investment.nil? ? nil : investment.round - end - - def company - @company || investment.company - end - - def shareholder - @shareholder || investment.shareholder end end end \ No newline at end of file