Class: Xirr::NewtonMethod::Function Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Base class for working with Newton’s Method.

Instance Method Summary collapse

Constructor Details

#initialize(transactions, function) ⇒ Function

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the Function with the Cashflow it will use as data source and the function to reduce it.

Parameters:

  • transactions (Cashflow)
  • function (Symbol)


31
32
33
34
# File 'lib/xirr/newton_method.rb', line 31

def initialize(transactions, function)
  @transactions = transactions
  @function = function
end

Instance Method Details

#values(x) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Necessary for #nlsolve

Parameters:

  • x (BigDecimal)


38
39
40
41
# 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