Class: MudratProjector::DateDiff::ComplexCalculator
- Inherits:
-
Calculator
- Object
- Struct
- Calculator
- MudratProjector::DateDiff::ComplexCalculator
- Defined in:
- lib/mudrat_projector/date_diff.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#first_unit ⇒ Object
readonly
Returns the value of attribute first_unit.
Attributes inherited from Calculator
Instance Method Summary collapse
- #calculate ⇒ Object
-
#initialize(*args) ⇒ ComplexCalculator
constructor
A new instance of ComplexCalculator.
Constructor Details
#initialize(*args) ⇒ ComplexCalculator
Returns a new instance of ComplexCalculator.
59 60 61 62 63 |
# File 'lib/mudrat_projector/date_diff.rb', line 59 def initialize *args super @first_unit = fetch_unit from @last_unit = fetch_unit to end |
Instance Attribute Details
#first_unit ⇒ Object (readonly)
Returns the value of attribute first_unit.
57 58 59 |
# File 'lib/mudrat_projector/date_diff.rb', line 57 def first_unit @first_unit end |
Instance Method Details
#calculate ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/mudrat_projector/date_diff.rb', line 65 def calculate if first_unit.begin == last_unit.begin days_between / days_in_unit(first_unit) else calculate_unit(from, first_unit.end) + units_between + calculate_unit(last_unit.begin, to) end end |