module TimeBoss::Calendars

Constants

Entry

Public Instance Methods

[](name) click to toggle source

Retrieve an instance of the specified named calendar. @param name [String, Symbol] the name of the calendar to retrieve. @return [Calendar]

# File lib/timeboss/calendars.rb, line 29
def [](name)
  return if @entries.nil?
  @entries[name&.to_sym]&.calendar
end
all() click to toggle source

Retrieve a list of all registered calendars. @return [Array<Entry>]

# 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) click to toggle source

Register a new calendar @return [Entry]

# 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