Class: Pipely::PipelineDateTime::PipelineYearRange

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

Overview

Class that represents a range of individual pipeline years

Constant Summary collapse

DAYS_IN_YEAR =
365

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) ⇒ PipelineYearRange

Returns a new instance of PipelineYearRange.



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

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

Instance Attribute Details

#endObject (readonly)

Returns the value of attribute end.



11
12
13
# File 'lib/pipely/pipeline_date_time/pipeline_year_range.rb', line 11

def end
  @end
end

#startObject (readonly)

Returns the value of attribute start.



11
12
13
# File 'lib/pipely/pipeline_date_time/pipeline_year_range.rb', line 11

def start
  @start
end

Instance Method Details

#yearsObject



20
21
22
# File 'lib/pipely/pipeline_date_time/pipeline_year_range.rb', line 20

def years
  @years ||= pipeline_dates.map { |pd| pd.year }
end