Class: Oldfixversion::Inner::Base
- Inherits:
-
Object
- Object
- Oldfixversion::Inner::Base
- Defined in:
- lib/oldfixversion/inner/base.rb
Constant Summary collapse
- CUTOFFS =
{ 'wednesday': { cutoff: '11:00 am MST', release: 'thursday' }, 'friday': { cutoff: '11:00 am MST', release: 'tuesday' } }.with_indifferent_access
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
Instance Method Summary collapse
- #before_cutoff_time? ⇒ Boolean
- #cutoff_day? ⇒ Boolean
- #cutoff_days ⇒ Object
- #cutoff_index ⇒ Object
- #cutoff_time ⇒ Object
- #cutoff_time_string ⇒ Object
- #day_of_week ⇒ Object
- #days_of_week_names ⇒ Object
- #dow_after_cutoff_time ⇒ Object
- #dow_before_cutoff_time ⇒ Object
- #fix_version ⇒ Object
-
#initialize(date) ⇒ Base
constructor
A new instance of Base.
- #next_cutoff ⇒ Object
- #next_cutoff_dow ⇒ Object
- #next_release_day ⇒ Object
Constructor Details
#initialize(date) ⇒ Base
Returns a new instance of Base.
20 21 22 |
# File 'lib/oldfixversion/inner/base.rb', line 20 def initialize(date) @date = date end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
18 19 20 |
# File 'lib/oldfixversion/inner/base.rb', line 18 def date @date end |
Instance Method Details
#before_cutoff_time? ⇒ Boolean
57 58 59 |
# File 'lib/oldfixversion/inner/base.rb', line 57 def before_cutoff_time? date < cutoff_time end |
#cutoff_day? ⇒ Boolean
32 33 34 |
# File 'lib/oldfixversion/inner/base.rb', line 32 def cutoff_day? CUTOFFS.keys.include?(day_of_week) end |
#cutoff_days ⇒ Object
24 25 26 |
# File 'lib/oldfixversion/inner/base.rb', line 24 def cutoff_days CUTOFFS.keys end |
#cutoff_index ⇒ Object
40 41 42 |
# File 'lib/oldfixversion/inner/base.rb', line 40 def cutoff_index CUTOFFS.keys.index(cutoff) end |
#cutoff_time ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/oldfixversion/inner/base.rb', line 48 def cutoff_time base = Time.parse(cutoff_time_string).to_datetime updated = base.change( day: date.day, month: date.month, year: date.year ) end |
#cutoff_time_string ⇒ Object
44 45 46 |
# File 'lib/oldfixversion/inner/base.rb', line 44 def cutoff_time_string '11:00 am MST' end |
#day_of_week ⇒ Object
28 29 30 |
# File 'lib/oldfixversion/inner/base.rb', line 28 def day_of_week date.strftime("%A").downcase end |
#days_of_week_names ⇒ Object
61 |
# File 'lib/oldfixversion/inner/base.rb', line 61 def days_of_week_names = Date::DAYNAMES.map(&:downcase) |
#dow_after_cutoff_time ⇒ Object
75 76 77 78 79 |
# File 'lib/oldfixversion/inner/base.rb', line 75 def dow_after_cutoff_time dow_index = days_of_week_names.index(day_of_week) rotated = days_of_week_names.rotate(dow_index + 1) rotated.detect { |dow| CUTOFFS.keys.include?(dow) } end |
#dow_before_cutoff_time ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/oldfixversion/inner/base.rb', line 67 def dow_before_cutoff_time return day_of_week if cutoff_day? dow_index = days_of_week_names.index(day_of_week) rotated = days_of_week_names.rotate(dow_index) rotated.detect { |dow| CUTOFFS.keys.include?(dow) } end |
#fix_version ⇒ Object
36 37 38 |
# File 'lib/oldfixversion/inner/base.rb', line 36 def fix_version next_release_day.strftime('%Y.%m.%d') end |
#next_cutoff ⇒ Object
63 64 65 |
# File 'lib/oldfixversion/inner/base.rb', line 63 def next_cutoff CUTOFFS[next_cutoff_dow] end |
#next_cutoff_dow ⇒ Object
81 82 83 84 85 |
# File 'lib/oldfixversion/inner/base.rb', line 81 def next_cutoff_dow return dow_before_cutoff_time if before_cutoff_time? dow_after_cutoff_time end |
#next_release_day ⇒ Object
87 88 89 90 |
# File 'lib/oldfixversion/inner/base.rb', line 87 def next_release_day next_release_dow = next_cutoff['release'] date.next_occurring(next_release_dow.to_sym) end |