Module: TimeBoss::Calendars

Extended by:
Enumerable, Calendars
Included in:
Calendars
Defined in:
lib/timeboss/calendars.rb,
lib/timeboss/calendars/broadcast.rb,
lib/timeboss/calendars/gregorian.rb

Defined Under Namespace

Classes: Broadcast, Entry, Gregorian

Instance Method Summary collapse

Instance Method Details

#[](name) ⇒ Calendar

Retrieve an instance of the specified named calendar.

Parameters:

  • name (String, Symbol)

    the name of the calendar to retrieve.

Returns:



29
30
31
32
# File 'lib/timeboss/calendars.rb', line 29

def [](name)
  return if @entries.nil?
  @entries[name&.to_sym]&.calendar
end

#allArray<Entry>

Retrieve a list of all registered calendars.

Returns:



21
22
23
24
# File 'lib/timeboss/calendars.rb', line 21

def all
  return if @entries.nil?
  @entries.values.sort_by { |e| e.name.to_s }
end

#register(name, klass) ⇒ Entry

Register a new calendar

Returns:



13
14
15
16
17
# File 'lib/timeboss/calendars.rb', line 13

def register(name, klass)
  Entry.new(name.to_sym, klass).tap do |entry|
    (@entries ||= {})[name.to_sym] = entry
  end
end