在辅助方法中没有从 if else 获得所需的结果

Not getting required result from if else in helper method

我已经使用助手来显示假期和树叶的背景颜色,我正在从这样的视图中调用助手方法 -

%th{:class => weekend_class_top(date)}= date.strftime("%d")

已调用的辅助方法 -

def weekend_class_top(date)
    if (date == date.end_of_month)
      'weekend_color5'
    elsif (date.to_s(:weekend) == 'Sun')  
      'weekend_color3'
    elsif @holidays.any?
      @holidays.map.each do |holiday|
        if (date == holiday)
          'timesheet_holiday_color'
        end
      end
    elsif @user_leaves.any?
      @user_leaves.flatten.map.each do |leave|
        if (date == leave)
          'timesheet_leave_color'
        end
      end
    end
  end

我写的代码,即使假期和假期都存在,我也只会为假期而不是假期获取背景颜色。

这是编辑的辅助方法 -

def weekend_class_top(date)
    if (date == date.end_of_month)
      'weekend_color5'
    elsif (date.to_s(:weekend) == 'Sun')  
      'weekend_color3'
    elsif @holidays.any?
      @holidays.map.each do |holiday|
        if @user_leaves.any?
          @user_leaves.flatten.map.each do |leave|
            if (date == leave)
              'timesheet_leave_color'
            end
          end
        elsif (date == holiday)
          'timesheet_holiday_color'
        end
      end
    end
  end

通过上面的书面方法,我只获得了叶子的背景颜色,但不是假期的背景颜色

这就是我得到正确结果的方式 -

def weekend_class_top(date)
    if (date == date.end_of_month)
      'weekend_color5'
    elsif (date.to_s(:weekend) == 'Sun')  
      'weekend_color3'
    elsif @holidays.include?(date)
      'timesheet_holiday_color'
    elsif @user_leaves.flatten.include?(date)
      'timesheet_leave_color'
    end
  end