Class: Finrb::Cashflow::Function Private

Inherits:
Object
  • Object
show all
Defined in:
lib/finrb/cashflows.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.

Returns a new instance of Function.



28
29
30
31
# File 'lib/finrb/cashflows.rb', line 28

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.



33
34
35
36
37
38
39
40
# File 'lib/finrb/cashflows.rb', line 33

def values(x)
  value = @transactions.public_send(@function, Flt::DecNum.new(x[0].to_s))
  begin
    [BigDecimal(value.to_s)]
  rescue ArgumentError
    [0]
  end
end