Class: Pipely::PipelineDateTime::PipelineMonthRange

Inherits:
PipelineDateRangeBase show all
Defined in:
lib/pipely/pipeline_date_time/pipeline_month_range.rb

Overview

Class that represents a range of individual pipeline months

Constant Summary collapse

MINIMUM_MONTH_OFFSET =

The month of x+/-30 will never add extra days

30
MONTH_INTERVAL =

We never miss a month by taking every 28 days

28

Instance Attribute Summary collapse

Attributes inherited from PipelineDateRangeBase

#days_back

Instance Method Summary collapse

Methods inherited from PipelineDateRangeBase

#exclude

Constructor Details

#initialize(target_date, days_back_start, days_back_end) ⇒ PipelineMonthRange

Returns a new instance of PipelineMonthRange.



14
15
16
17
18
19
# File 'lib/pipely/pipeline_date_time/pipeline_month_range.rb', line 14

def initialize(target_date, days_back_start, days_back_end)
  @target_date = target_date
  @start = days_back_start - MINIMUM_MONTH_OFFSET
  @end = days_back_end + MINIMUM_MONTH_OFFSET
  @days_back = (@end..@start).step(MONTH_INTERVAL).to_set
end

Instance Attribute Details

#endObject (readonly)

Returns the value of attribute end.



12
13
14
# File 'lib/pipely/pipeline_date_time/pipeline_month_range.rb', line 12

def end
  @end
end

#startObject (readonly)

Returns the value of attribute start.



12
13
14
# File 'lib/pipely/pipeline_date_time/pipeline_month_range.rb', line 12

def start
  @start
end

Instance Method Details

#monthsObject



21
22
23
# File 'lib/pipely/pipeline_date_time/pipeline_month_range.rb', line 21

def months
  @months ||= pipeline_dates.map { |pd| pd.month }
end