Class: TimeBoss::Calendar

Inherits:
Object
  • Object
show all
Includes:
Waypoints
Defined in:
lib/timeboss/calendar.rb,
lib/timeboss/calendar/day.rb,
lib/timeboss/calendar/half.rb,
lib/timeboss/calendar/week.rb,
lib/timeboss/calendar/year.rb,
lib/timeboss/calendar/month.rb,
lib/timeboss/calendar/parser.rb,
lib/timeboss/calendar/period.rb,
lib/timeboss/calendar/quarter.rb,
lib/timeboss/calendar/waypoints.rb,
lib/timeboss/calendar/support/unit.rb,
lib/timeboss/calendar/support/formatter.rb,
lib/timeboss/calendar/support/navigable.rb,
lib/timeboss/calendar/support/shiftable.rb,
lib/timeboss/calendar/waypoints/absolute.rb,
lib/timeboss/calendar/waypoints/relative.rb,
lib/timeboss/calendar/support/month_basis.rb,
lib/timeboss/calendar/support/monthly_unit.rb,
lib/timeboss/calendar/support/translatable.rb,
lib/timeboss/calendar/support/has_iso_weeks.rb,
lib/timeboss/calendar/support/has_fiscal_weeks.rb

Defined Under Namespace

Modules: Support, Waypoints Classes: Day, Half, Month, Parser, Period, Quarter, Week, Year

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Waypoints::Relative

#days_ago, #days_ahead, #days_back, #days_for, #days_forward, #halves_ago, #halves_ahead, #halves_back, #halves_for, #halves_forward, #last_day, #last_half, #last_month, #last_quarter, #last_week, #last_year, #months_ago, #months_ahead, #months_back, #months_for, #months_forward, #next_day, #next_half, #next_month, #next_quarter, #next_week, #next_year, #quarters_ago, #quarters_ahead, #quarters_back, #quarters_for, #quarters_forward, #this_day, #this_half, #this_month, #this_quarter, #this_week, #this_year, #weeks_ago, #weeks_ahead, #weeks_back, #weeks_for, #weeks_forward, #years_ago, #years_ahead, #years_back, #years_for, #years_forward

Methods included from Waypoints::Absolute

#day, #day_for, #half, #half_for, #month, #month_for, #quarter, #quarter_for, #week, #week_for, #year, #year_for

Constructor Details

#initialize(basis:) ⇒ Calendar (protected)

Returns a new instance of Calendar.



55
56
57
# File 'lib/timeboss/calendar.rb', line 55

def initialize(basis:)
  @basis = basis
end

Instance Attribute Details

#basisObject (readonly, protected)

Returns the value of attribute basis.



53
54
55
# File 'lib/timeboss/calendar.rb', line 53

def basis
  @basis
end

Instance Method Details

#nameString Also known as: to_s

Get a name by which this calendar can be referenced.

Returns:

  • (String)


26
27
28
# File 'lib/timeboss/calendar.rb', line 26

def name
  self.class.to_s.demodulize.underscore
end

#parseSupport::Unit, Period

Parse an identifier into a unit or period.

Valid identifiers can include simple units (like "2020Q3", "2020M8W3", "last_quarter"),
mathematical expressions (like "this_month+6"),
or period expressions (like "2020W1..2020W8", "this_quarter-2..next_quarter")

Parameters:

  • identifier (String)

Returns:



22
# File 'lib/timeboss/calendar.rb', line 22

delegate :parse, to: :parser

#supports_weeks?Boolean

Can this calendar support weeks? To support weeks, a calendar must implement a ‘#weeks_in(year:)` method that returns an array of `Calendar::Week` objects.

Returns:

  • (Boolean)


41
42
43
# File 'lib/timeboss/calendar.rb', line 41

def supports_weeks?
  respond_to?(:weeks_in)
end

#titleString

Get a friendly title for this calendar.

Returns:

  • (String)


33
34
35
# File 'lib/timeboss/calendar.rb', line 33

def title
  name.titleize
end