Class: TimeBoss::Calendar::Support::MonthlyUnit
- Defined in:
- lib/timeboss/calendar/support/monthly_unit.rb
Constant Summary
Constants inherited from Unit
Constants included from Translatable
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#year_index ⇒ Object
readonly
Returns the value of attribute year_index.
Attributes inherited from Unit
#calendar, #end_date, #start_date
Instance Method Summary collapse
-
#initialize(calendar, year_index, index, start_date, end_date) ⇒ MonthlyUnit
constructor
A new instance of MonthlyUnit.
-
#to_s ⇒ String
Get a stringified representation of this unit.
-
#weeks ⇒ Array<Week>
Get a list of weeks contained within this period.
Methods inherited from Unit
#+, #-, #==, #current?, #dates, #format, #inspect, #offset, #thru, #to_range, type
Methods included from Shiftable
#days_ago, #days_ahead, #halves_ago, #halves_ahead, #in_day, #in_half, #in_month, #in_quarter, #in_week, #in_year, #last_day, #last_half, #last_month, #last_quarter, #last_week, #last_year, #months_ago, #months_ahead, #next_day, #next_half, #next_month, #next_quarter, #next_week, #next_year, #quarters_ago, #quarters_ahead, #this_day, #this_half, #this_month, #this_quarter, #this_week, #this_year, #weeks_ago, #weeks_ahead, #years_ago, #years_ahead
Methods included from Translatable
#day, #days, #half, #halves, #month, #months, #quarter, #quarters, #week, #year, #years
Methods included from Navigable
#ago, #ahead, #next, #previous, #until
Constructor Details
#initialize(calendar, year_index, index, start_date, end_date) ⇒ MonthlyUnit
Returns a new instance of MonthlyUnit.
11 12 13 14 15 |
# 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 |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
9 10 11 |
# File 'lib/timeboss/calendar/support/monthly_unit.rb', line 9 def index @index end |
#year_index ⇒ Object (readonly)
Returns the value of attribute year_index.
9 10 11 |
# File 'lib/timeboss/calendar/support/monthly_unit.rb', line 9 def year_index @year_index end |
Instance Method Details
#to_s ⇒ String
Get a stringified representation of this unit.
19 20 21 |
# File 'lib/timeboss/calendar/support/monthly_unit.rb', line 19 def to_s "#{name}: #{start_date} thru #{end_date}" end |
#weeks ⇒ Array<Week>
Get a list of weeks contained within this period.
25 26 27 28 29 |
# File 'lib/timeboss/calendar/support/monthly_unit.rb', line 25 def weeks raise UnsupportedUnitError unless calendar.supports_weeks? base = calendar.year(year_index) calendar.weeks_in(year: base).select { |w| (w.dates & dates).count >= 4 } end |