Class: CashFlowAnalysis::Util::ObjectiveFunction
- Inherits:
-
Object
- Object
- CashFlowAnalysis::Util::ObjectiveFunction
- Defined in:
- lib/cash_flow_analysis/util/objective_function.rb
Instance Method Summary collapse
- #eps ⇒ Object
-
#initialize(calculator, cash_flow_items) ⇒ ObjectiveFunction
constructor
A new instance of ObjectiveFunction.
- #one ⇒ Object
- #ten ⇒ Object
- #two ⇒ Object
- #values(discount_rates) ⇒ Object
- #zero ⇒ Object
Constructor Details
#initialize(calculator, cash_flow_items) ⇒ ObjectiveFunction
Returns a new instance of 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
#eps ⇒ Object
4 5 6 |
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 4 def eps BigDecimal.new("1.0e-16") end |
#one ⇒ Object
12 13 14 |
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 12 def one BigDecimal.new("1.0") end |
#ten ⇒ Object
20 21 22 |
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 20 def ten BigDecimal.new("10.0") end |
#two ⇒ Object
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 |
#zero ⇒ Object
8 9 10 |
# File 'lib/cash_flow_analysis/util/objective_function.rb', line 8 def zero BigDecimal.new("0.0") end |