Sha256: c59d70880438f2378e755ec0024ccfca8f5f4c4b86ac28e0e34561551d140cb5
Contents?: true
Size: 669 Bytes
Versions: 3
Compression:
Stored size: 669 Bytes
Contents
# frozen_string_literal: true require 'active_support/core_ext/class/subclasses' require_relative 'calendar' Dir[File.expand_path('../calendars/*.rb', __FILE__)].each { |f| require f } module TimeBoss module Calendars extend self extend Enumerable delegate :each, :length, to: :all def all @_all ||= TimeBoss::Calendar.subclasses.map do |klass| Entry.new(klass.to_s.demodulize.underscore.to_sym, klass) end end def [](name) find { |e| e.name == name&.to_sym }&.calendar end private Entry = Struct.new(:name, :klass) do def calendar @_calendar ||= klass.new end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
timeboss-0.0.10 | lib/timeboss/calendars.rb |
timeboss-0.0.9 | lib/timeboss/calendars.rb |
timeboss-0.0.8 | lib/timeboss/calendars.rb |