class Xirr::NewtonMethod::Function

Base class for working with Newton's Method. @api private

Public Class Methods

new(transactions, function) click to toggle source

@param transactions [Cashflow] @param function [Symbol] Initializes the Function with the Cashflow it will use as data source and the function to reduce it.

# File lib/xirr/newton_method.rb, line 31
def initialize(transactions, function)
  @transactions = transactions
  @function = function
end

Public Instance Methods

values(x) click to toggle source

Necessary for nlsolve @param x [BigDecimal]

# File lib/xirr/newton_method.rb, line 38
def values(x)
  value = @transactions.send(@function, BigDecimal(x[0].to_s, Xirr::PRECISION))
  [BigDecimal(value.to_s, Xirr::PRECISION)]
end