Module: Increments::Schedule
- Extended by:
- Schedule
- Included in:
- Schedule
- Defined in:
- lib/increments/schedule.rb,
lib/increments/schedule/version.rb
Constant Summary collapse
- DATE_OF_SPECIAL_TGIF_PARTY =
Date.new(2015, 6, 19)
- START_DATE_OF_NORMAL_TGIF_PARTY_SCHEDULE =
Date.new(2015, 7, 1)
- VERSION =
'0.7.0'
Instance Method Summary collapse
- #each_work_time_range(max_date = nil) ⇒ Object
- #holiday?(date = Date.today) ⇒ Boolean
- #normal_remote_work_day?(date = Date.today) ⇒ Boolean
- #office_work_day?(date = Date.today) ⇒ Boolean
- #pay_day?(date = Date.today) ⇒ Boolean
- #remote_work_day?(date = Date.today) ⇒ Boolean
- #rest_day?(date = Date.today) ⇒ Boolean
- #special_remote_work_day?(date = Date.today) ⇒ Boolean
- #super_hanakin?(date = Date.today) ⇒ Boolean
- #tgif_party_day?(date = Date.today) ⇒ Boolean
- #weekend?(date = Date.today) ⇒ Boolean
- #work_day?(date = Date.today) ⇒ Boolean
Instance Method Details
#each_work_time_range(max_date = nil) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/increments/schedule.rb', line 79 def each_work_time_range(max_date = nil) return to_enum(__method__, max_date) unless block_given? each_work_day(max_date) do |work_day| yield opening_time_of_date(work_day)..closing_time_of_date(work_day) end end |
#holiday?(date = Date.today) ⇒ Boolean
61 62 63 |
# File 'lib/increments/schedule.rb', line 61 def holiday?(date = Date.today) HolidayJapan.check(date) end |
#normal_remote_work_day?(date = Date.today) ⇒ Boolean
44 45 46 |
# File 'lib/increments/schedule.rb', line 44 def normal_remote_work_day?(date = Date.today) date.monday? && work_day?(date) end |
#office_work_day?(date = Date.today) ⇒ Boolean
36 37 38 |
# File 'lib/increments/schedule.rb', line 36 def office_work_day?(date = Date.today) work_day?(date) && !remote_work_day?(date) end |
#pay_day?(date = Date.today) ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/increments/schedule.rb', line 23 def pay_day?(date = Date.today) return work_day?(date) if date.day == 25 next_basic_pay_day = Date.new(date.year, date.month, 25) next_basic_pay_day = next_basic_pay_day.next_month if date > next_basic_pay_day date.next_day.upto(next_basic_pay_day).all? do |date_until_basic_pay_day| rest_day?(date_until_basic_pay_day) end end |
#remote_work_day?(date = Date.today) ⇒ Boolean
40 41 42 |
# File 'lib/increments/schedule.rb', line 40 def remote_work_day?(date = Date.today) normal_remote_work_day?(date) || special_remote_work_day?(date) end |
#rest_day?(date = Date.today) ⇒ Boolean
53 54 55 |
# File 'lib/increments/schedule.rb', line 53 def rest_day?(date = Date.today) weekend?(date) || holiday?(date) end |
#special_remote_work_day?(date = Date.today) ⇒ Boolean
48 49 50 51 |
# File 'lib/increments/schedule.rb', line 48 def special_remote_work_day?(date = Date.today) normal_office_work_day?(date) && !normal_office_work_day?(date - 1) && !normal_office_work_day?(date + 1) end |
#super_hanakin?(date = Date.today) ⇒ Boolean
11 12 13 |
# File 'lib/increments/schedule.rb', line 11 def super_hanakin?(date = Date.today) date.friday? && pay_day?(date) end |
#tgif_party_day?(date = Date.today) ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/increments/schedule.rb', line 15 def tgif_party_day?(date = Date.today) if date >= START_DATE_OF_NORMAL_TGIF_PARTY_SCHEDULE date.friday? && (date.day / 7).odd? && work_day?(date) else date == DATE_OF_SPECIAL_TGIF_PARTY end end |
#weekend?(date = Date.today) ⇒ Boolean
57 58 59 |
# File 'lib/increments/schedule.rb', line 57 def weekend?(date = Date.today) date.saturday? || date.sunday? end |
#work_day?(date = Date.today) ⇒ Boolean
32 33 34 |
# File 'lib/increments/schedule.rb', line 32 def work_day?(date = Date.today) !rest_day?(date) end |