class BankWorkingDay::Holidays

Constants

HOLIDAY_WDAYS

Attributes

bank_holidays[RW]
holidays[RW]

Public Class Methods

new(holidays_yml_path) click to toggle source
# File lib/bank_working_day/holidays.rb, line 16
def initialize(holidays_yml_path)
  @holidays = set_holiday(holidays_yml_path)
  @bank_holidays = set_holiday('../../../bank_holidays.yml')
end

Public Instance Methods

holiday?(date) click to toggle source
# File lib/bank_working_day/holidays.rb, line 21
def holiday?(date)
  holidays[date] || bank_holidays[date] || date.wday.in?(HOLIDAY_WDAYS)
end

Private Instance Methods

set_holiday(path) click to toggle source
# File lib/bank_working_day/holidays.rb, line 27
def set_holiday(path)
  yaml = YAML.load_file(File.expand_path(path, __FILE__))
  yaml.each_with_object({}) do |(key, value), hash|
    hash[key] = Holiday.new(key, value)
  end
end