Class: Pipely::PipelineDateTime::PipelineDate
- Inherits:
-
Object
- Object
- Pipely::PipelineDateTime::PipelineDate
- Defined in:
- lib/pipely/pipeline_date_time/pipeline_date.rb
Overview
Encapsulates AWS pipeline date
Constant Summary collapse
- DEFAULT_DAY_FORMAT =
'YYYY/MM/dd'
- DEFAULT_MONTH_FORMAT =
'YYYY/MM'
- DEFAULT_YEAR_FORMAT =
'YYYY'
Class Method Summary collapse
- .day_format ⇒ Object
- .day_format=(day_format) ⇒ Object
- .month_format ⇒ Object
- .month_format=(month_format) ⇒ Object
- .year_format ⇒ Object
- .year_format=(year_format) ⇒ Object
Instance Method Summary collapse
- #day ⇒ Object
-
#initialize(target_date, days_back) ⇒ PipelineDate
constructor
A new instance of PipelineDate.
- #month ⇒ Object
- #year ⇒ Object
Constructor Details
#initialize(target_date, days_back) ⇒ PipelineDate
Returns a new instance of PipelineDate.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 37 def initialize(target_date, days_back) days_back = days_back.to_i @date_expression = case when days_back > 0 "minusDays(#{target_date}, #{days_back})" when days_back == 0 target_date else "plusDays(#{target_date}, #{-days_back})" end end |
Class Method Details
.day_format ⇒ Object
16 17 18 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 16 def day_format @day_format || DEFAULT_DAY_FORMAT end |
.day_format=(day_format) ⇒ Object
12 13 14 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 12 def day_format=(day_format) @day_format = day_format end |
.month_format ⇒ Object
24 25 26 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 24 def month_format @month_format || DEFAULT_MONTH_FORMAT end |
.month_format=(month_format) ⇒ Object
20 21 22 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 20 def month_format=(month_format) @month_format = month_format end |
.year_format ⇒ Object
32 33 34 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 32 def year_format @year_format || DEFAULT_YEAR_FORMAT end |
.year_format=(year_format) ⇒ Object
28 29 30 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 28 def year_format=(year_format) @year_format = year_format end |
Instance Method Details
#day ⇒ Object
49 50 51 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 49 def day "\#{format(#{@date_expression}, \"#{PipelineDate.day_format}\")}" end |
#month ⇒ Object
53 54 55 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 53 def month "\#{format(#{@date_expression}, \"#{PipelineDate.month_format}\")}" end |
#year ⇒ Object
57 58 59 |
# File 'lib/pipely/pipeline_date_time/pipeline_date.rb', line 57 def year "\#{format(#{@date_expression}, \"#{PipelineDate.year_format}\")}" end |