Module: ScheduleAttributes::Input::RepeatingDates

Defined in:
lib/schedule_attributes/input.rb

Instance Method Summary collapse

Instance Method Details

#intervalFixnum

Defaults to 1

Returns:

  • (Fixnum)


12
13
14
# File 'lib/schedule_attributes/input.rb', line 12

def interval
  @params.fetch(:interval, 1).to_i
end

#interval_unitObject



16
17
18
# File 'lib/schedule_attributes/input.rb', line 16

def interval_unit
  @params[:interval_unit] if repeat?
end

#ordinal_dayObject



28
29
30
# File 'lib/schedule_attributes/input.rb', line 28

def ordinal_day
  @params.fetch(:ordinal_day, 1).to_i
end

#ordinal_unitObject



20
21
22
# File 'lib/schedule_attributes/input.rb', line 20

def ordinal_unit
  @params[:ordinal_unit].to_sym if @params[:ordinal_unit]
end

#ordinal_weekObject



24
25
26
# File 'lib/schedule_attributes/input.rb', line 24

def ordinal_week
  @params.fetch(:ordinal_week, 1).to_i
end

#repeat?Boolean

Returns:

  • (Boolean)


7
# File 'lib/schedule_attributes/input.rb', line 7

def repeat?; true end

#weekdaysObject



73
74
75
# File 'lib/schedule_attributes/input.rb', line 73

def weekdays
  IceCube::TimeUtil::DAYS.keys.select { |day| @params[day].to_i == 1 }
end

#yearly_end_monthObject



37
38
39
40
# File 'lib/schedule_attributes/input.rb', line 37

def yearly_end_month
  return unless yearly_end_month?
  @params[:yearly_end_month].to_i
end

#yearly_end_month?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/schedule_attributes/input.rb', line 56

def yearly_end_month?
  @params[:yearly_end_month].present?
end

#yearly_end_month_dayObject



47
48
49
50
# File 'lib/schedule_attributes/input.rb', line 47

def yearly_end_month_day
  return unless yearly_end_month_day?
  @params[:yearly_end_month_day].to_i
end

#yearly_end_month_day?Boolean

Returns:

  • (Boolean)


67
68
69
70
71
# File 'lib/schedule_attributes/input.rb', line 67

def yearly_end_month_day?
  @params[:yearly_end_month].present? &&
  @params[:yearly_end_month_day].present? &&
  @params[:yearly_end_month_day].to_i < Time.days_in_month(@params[:yearly_end_month].to_i)
end

#yearly_start_monthObject



32
33
34
35
# File 'lib/schedule_attributes/input.rb', line 32

def yearly_start_month
  return unless yearly_start_month?
  @params[:yearly_start_month].to_i
end

#yearly_start_month?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/schedule_attributes/input.rb', line 52

def yearly_start_month?
  @params[:yearly_start_month].present?
end

#yearly_start_month_dayObject



42
43
44
45
# File 'lib/schedule_attributes/input.rb', line 42

def yearly_start_month_day
  return unless yearly_start_month_day?
  @params[:yearly_start_month_day].to_i
end

#yearly_start_month_day?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
65
# File 'lib/schedule_attributes/input.rb', line 60

def yearly_start_month_day?
  [ @params[:yearly_start_month].present?,
    @params[:yearly_start_month_day].present?,
    @params[:yearly_start_month_day].to_i > 1
  ].all?
end