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)


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

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)


39
40
41
42
# File 'lib/xirr/newton_method.rb', line 39

def values(x)
  value = @transactions.send(@function, BigDecimal(x[0].to_s, Xirr.config.precision))
  [BigDecimal(value.to_s, Xirr.config.precision)]
end