class TimeBoss::Calendar::Support::MonthlyUnit
Attributes
index[R]
year_index[R]
Public Class Methods
new(calendar, year_index, index, start_date, end_date)
click to toggle source
Calls superclass method
# File lib/timeboss/calendar/support/monthly_unit.rb, line 11 def initialize(calendar, year_index, index, start_date, end_date) super(calendar, start_date, end_date) @year_index = year_index @index = index end
Public Instance Methods
to_s()
click to toggle source
Get a stringified representation of this unit. @return [String] (e.g. “2020Q3: 2020-06-29 thru 2020-09-27”)
# File lib/timeboss/calendar/support/monthly_unit.rb, line 19 def to_s "#{name}: #{start_date} thru #{end_date}" end
weeks()
click to toggle source
Get a list of weeks contained within this period. @return [Array<Week>]
# File lib/timeboss/calendar/support/monthly_unit.rb, line 25 def weeks base = calendar.year(year_index) num_weeks = (((base.end_date - base.start_date) + 1) / 7.0).to_i num_weeks.times.map { |i| Week.new(calendar, base.start_date + (i * 7).days, base.start_date + ((i * 7) + 6).days) } .select { |w| w.start_date.between?(start_date, end_date) } end
Private Instance Methods
down()
click to toggle source
# File lib/timeboss/calendar/support/monthly_unit.rb, line 46 def down if index == 1 calendar.public_send(self.class.type, year_index - 1, max_index) else calendar.public_send(self.class.type, year_index, index - 1) end end
max_index()
click to toggle source
# File lib/timeboss/calendar/support/monthly_unit.rb, line 34 def max_index 12 / self.class::NUM_MONTHS end
up()
click to toggle source
# File lib/timeboss/calendar/support/monthly_unit.rb, line 38 def up if index == max_index calendar.public_send(self.class.type, year_index + 1, 1) else calendar.public_send(self.class.type, year_index, index + 1) end end