Method: SimpleCalendar::Calendar#td_classes_for

Defined in:
lib/simple_calendar/calendar.rb

#td_classes_for(day) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/simple_calendar/calendar.rb', line 42

def td_classes_for(day)
  today = Date.current

  td_class = ["day"]
  td_class << "wday-#{day.wday}"
  td_class << "today" if today == day
  td_class << "past" if today > day
  td_class << "future" if today < day
  td_class << "start-date" if day.to_date == start_date.to_date
  td_class << "prev-month" if start_date.month != day.month && day < start_date
  td_class << "next-month" if start_date.month != day.month && day > start_date
  td_class << "current-month" if start_date.month == day.month
  td_class << "has-events" if sorted_events.fetch(day, []).any?

  td_class
end