Class: CashFlowAnalysis::Util::ObjectiveFunction

Inherits:
Object
  • Object
show all
Defined in:
lib/cash_flow_analysis/util/objective_function.rb

Instance Method Summary collapse

Constructor Details

#initialize(calculator, cash_flow_items) ⇒ ObjectiveFunction


24
25
26
27
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 24

def initialize(calculator, cash_flow_items)
  @calculator = calculator
  @cash_flow_items = cash_flow_items
end

Instance Method Details

#epsObject


4
5
6
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 4

def eps
  BigDecimal.new("1.0e-16")
end

#oneObject


12
13
14
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 12

def one
  BigDecimal.new("1.0")
end

#tenObject


20
21
22
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 20

def ten
  BigDecimal.new("10.0")
end

#twoObject


16
17
18
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 16

def two
  BigDecimal.new("2.0")
end

#values(discount_rates) ⇒ Object


29
30
31
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 29

def values(discount_rates)
  [calculator.calculate(discount_rates.first.round(15), cash_flow_items)]
end

#zeroObject


8
9
10
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 8

def zero
  BigDecimal.new("0.0")
end