class Cronline::CronDaysOfMonth

Public Class Methods

new(cron_expression) click to toggle source
Calls superclass method
# File lib/cronline/cron_days_of_month.rb, line 5
def initialize(cron_expression)
  @field_expression = cron_expression.split(' ')[3]
  if @field_expression == 'L'
    @last_day_of_month = true
    @field_expression.sub!('L', '')
  else
    super(@field_expression, 0, 31)
  end
end

Public Instance Methods

active?() click to toggle source
# File lib/cronline/cron_days_of_month.rb, line 15
def active?
  @field_expression != '?'
end
range(time) click to toggle source
Calls superclass method
# File lib/cronline/cron_days_of_month.rb, line 23
def range(time)
  if @last_day_of_month
    puts @last_day_of_month
    [last_day_of_month(time)]
  else
    super(time)
  end
end
time_field(time) click to toggle source
# File lib/cronline/cron_days_of_month.rb, line 19
def time_field(time)
  time.day
end

Private Instance Methods

last_day_of_month(time) click to toggle source
# File lib/cronline/cron_days_of_month.rb, line 34
def last_day_of_month(time)
    Date.new(time.year, time.month, -1).day
end