Method: Cronex::DayOfWeekDescription#description_format

Defined in:
lib/cronex/description/day_of_week.rb

#description_format(expression) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cronex/description/day_of_week.rb', line 34

def description_format(expression)
  if expression.include?('#')
    dow_num = expression.split('#').last
    days = Hash[%w(1 2 3 4 5).zip(%w(first second third fourth fifth))]
    dow_desc = days[dow_num]
    dow_desc = dow_desc ? resources.get(dow_desc) : ''
    ', ' + resources.get('on_the_day_of_the_month').gsub(/{{.*}}/, dow_desc)
  elsif expression.include?('L')
    ', ' + resources.get('on_the_last_of_the_month')
  else
    ', ' + resources.get('only_on')
  end
end