Class: MudratProjector::DateDiff::YearCalculator

Inherits:
ComplexCalculator show all
Defined in:
lib/mudrat_projector/date_diff.rb

Instance Attribute Summary

Attributes inherited from ComplexCalculator

#first_unit

Attributes inherited from Calculator

#from, #to

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ComplexCalculator

#calculate, #initialize

Methods inherited from Calculator

#calculate

Constructor Details

This class inherits a constructor from MudratProjector::DateDiff::ComplexCalculator

Class Method Details

.advance(intervals, from: from) ⇒ Object



115
116
117
# File 'lib/mudrat_projector/date_diff.rb', line 115

def self.advance intervals, from: from
  Date.new(from.year + intervals, from.month, from.day)
end

Instance Method Details

#advance_one_unit(date) ⇒ Object



107
108
109
# File 'lib/mudrat_projector/date_diff.rb', line 107

def advance_one_unit date
  date.next_year
end

#fetch_unit(date) ⇒ Object



103
104
105
# File 'lib/mudrat_projector/date_diff.rb', line 103

def fetch_unit date
  (Date.new(date.year)..Date.new(date.year, 12, 31))
end

#rewind_one_unit(date) ⇒ Object



111
112
113
# File 'lib/mudrat_projector/date_diff.rb', line 111

def rewind_one_unit date
  date.prev_year
end