class DeployLog::Calendar
Public Instance Methods
week(week_num)
click to toggle source
# File lib/deploy_log/calendar.rb, line 5 def week(week_num) year_calendar(2019).to_a[week_num] end
Private Instance Methods
range_for(year)
click to toggle source
# File lib/deploy_log/calendar.rb, line 11 def range_for(year) start = Date.parse("#{year}-01-01") finish = Date.parse("#{year}-12-31") (start..finish) end
year_calendar(year)
click to toggle source
# File lib/deploy_log/calendar.rb, line 18 def year_calendar(year) date_range = range_for(year) output = (1..52).to_a.map { |w| { w => [] } } date_range.each do |day| output[day.cweek] = {} output[day.cweek][:first] = (day - 7).to_time output[day.cweek][:last] = day.to_time + (24 * 60 * 60) - 1 end output end