Class: InterestDays::Calculator
- Inherits:
-
Object
- Object
- InterestDays::Calculator
- Defined in:
- lib/interest_days/calculator.rb
Overview
Main calculator class
Instance Attribute Summary collapse
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#strategy ⇒ Object
Returns the value of attribute strategy.
Instance Method Summary collapse
-
#initialize(start_date:, end_date:, strategy:) ⇒ Calculator
constructor
A new instance of Calculator.
- #interest_day_count_factor ⇒ Object
Constructor Details
#initialize(start_date:, end_date:, strategy:) ⇒ Calculator
Returns a new instance of Calculator.
8 9 10 11 12 |
# File 'lib/interest_days/calculator.rb', line 8 def initialize(start_date:, end_date:, strategy:) @start_date = start_date @end_date = end_date @strategy = strategies[strategy.to_sym] end |
Instance Attribute Details
#end_date ⇒ Object
Returns the value of attribute end_date.
6 7 8 |
# File 'lib/interest_days/calculator.rb', line 6 def end_date @end_date end |
#start_date ⇒ Object
Returns the value of attribute start_date.
6 7 8 |
# File 'lib/interest_days/calculator.rb', line 6 def start_date @start_date end |
#strategy ⇒ Object
Returns the value of attribute strategy.
6 7 8 |
# File 'lib/interest_days/calculator.rb', line 6 def strategy @strategy end |
Instance Method Details
#interest_day_count_factor ⇒ Object
14 15 16 17 18 |
# File 'lib/interest_days/calculator.rb', line 14 def interest_day_count_factor raise StandardError, "Strategy is not set" if @strategy.nil? @strategy.new(start_date: @start_date, end_date: @end_date).day_count_factor end |