Module: BankWorkingDay

Defined in:
lib/bank_working_day.rb,
lib/bank_working_day/version.rb,
lib/bank_working_day/holidays.rb

Defined Under Namespace

Classes: Holiday, Holidays

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.end_of_month_without_holiday(date) ⇒ Object



7
8
9
10
11
12
# File 'lib/bank_working_day.rb', line 7

def self.end_of_month_without_holiday(date)
  date.end_of_month.day.downto(1) do |last_day|
    last_day = Date.new(date.year, date.month, last_day)
    return last_day unless holidays.holiday?(last_day)
  end
end

.holiday?(date) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/bank_working_day.rb', line 23

def self.holiday?(date)
  holidays.holiday?(date)
end

.working_day_before(date:, offset:) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/bank_working_day.rb', line 14

def self.working_day_before(date: , offset: )
  offset.times do |i|
    date -= 1
    date -= 1 while holiday?(date)
  end

  date
end