Module: FestiveErrors

Defined in:
lib/festive_errors.rb,
lib/festive_errors/engine.rb,
lib/festive_errors/version.rb,
lib/festive_errors/debug_exceptions_extension.rb

Defined Under Namespace

Modules: DebugExceptionsExtension Classes: Engine

Constant Summary collapse

VERSION =
"0.0.2"
THEMES =
{
  christmas: "christmas.css",
  halloween: "halloween.css",
  valentines: "valentines.css",
  thanksgiving: "thanksgiving.css",
  newyears: "newyears.css"
}.freeze

Class Method Summary collapse

Class Method Details

.current_themeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/festive_errors/debug_exceptions_extension.rb', line 20

def self.current_theme
  today = Date.today
  year = today.year

  # Get holiday ranges for current year
  ranges = FestiveErrors.holiday_ranges(year)

  # Check if today falls within a holiday range
  ranges.each do |theme, date_range|
    if date_range.cover?(today)
      return theme
    end
  end

  # Also check ranges from previous year (for dates that span multiple years)
  if today.month == 1
    prev_ranges = FestiveErrors.holiday_ranges(year - 1)
    prev_ranges.each do |theme, date_range|
      if date_range.cover?(today)
        return theme
      end
    end
  end

  nil # No theme if not within a holiday range
end

.holiday_ranges(year) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/festive_errors/debug_exceptions_extension.rb', line 10

def self.holiday_ranges(year)
  {
    christmas: Date.new(year, 12, 1)..Date.new(year, 12, 30),
    halloween: Date.new(year, 10, 1)..Date.new(year, 10, 31),
    valentines: (Date.new(year, 2, 14) - 7)..Date.new(year, 2, 14),
    thanksgiving: Date.new(year, 11, 1)..Date.new(year, 11, 30),
    newyears: Date.new(year, 12, 31)..Date.new(year + 1, 1, 1)
  }
end