Module: ScheduleAttributes::Input::RepeatingDates
- Defined in:
- lib/schedule_attributes/input.rb
Instance Method Summary collapse
-
#interval ⇒ Fixnum
Defaults to 1.
- #interval_unit ⇒ Object
- #ordinal_day ⇒ Object
- #ordinal_unit ⇒ Object
- #ordinal_week ⇒ Object
- #repeat? ⇒ Boolean
- #weekdays ⇒ Object
- #yearly_end_month ⇒ Object
- #yearly_end_month? ⇒ Boolean
- #yearly_end_month_day ⇒ Object
- #yearly_end_month_day? ⇒ Boolean
- #yearly_start_month ⇒ Object
- #yearly_start_month? ⇒ Boolean
- #yearly_start_month_day ⇒ Object
- #yearly_start_month_day? ⇒ Boolean
Instance Method Details
#interval ⇒ Fixnum
Defaults to 1
12 13 14 |
# File 'lib/schedule_attributes/input.rb', line 12 def interval @params.fetch(:interval, 1).to_i end |
#interval_unit ⇒ Object
16 17 18 |
# File 'lib/schedule_attributes/input.rb', line 16 def interval_unit @params[:interval_unit] if repeat? end |
#ordinal_day ⇒ Object
28 29 30 |
# File 'lib/schedule_attributes/input.rb', line 28 def ordinal_day @params.fetch(:ordinal_day, 1).to_i end |
#ordinal_unit ⇒ Object
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_week ⇒ Object
24 25 26 |
# File 'lib/schedule_attributes/input.rb', line 24 def ordinal_week @params.fetch(:ordinal_week, 1).to_i end |
#repeat? ⇒ Boolean
7 |
# File 'lib/schedule_attributes/input.rb', line 7 def repeat?; true end |
#weekdays ⇒ Object
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_month ⇒ Object
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
56 57 58 |
# File 'lib/schedule_attributes/input.rb', line 56 def yearly_end_month? @params[:yearly_end_month].present? end |
#yearly_end_month_day ⇒ Object
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
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_month ⇒ Object
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
52 53 54 |
# File 'lib/schedule_attributes/input.rb', line 52 def yearly_start_month? @params[:yearly_start_month].present? end |
#yearly_start_month_day ⇒ Object
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
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 |