aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/bank_holidays_cache.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mauve/bank_holidays_cache.rb')
-rw-r--r--lib/mauve/bank_holidays_cache.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/mauve/bank_holidays_cache.rb b/lib/mauve/bank_holidays_cache.rb
new file mode 100644
index 0000000..ce50663
--- /dev/null
+++ b/lib/mauve/bank_holidays_cache.rb
@@ -0,0 +1,28 @@
+require 'mauve/calendar_interface'
+
+module Mauve
+
+ class BankHolidaysCache
+ def initialize
+ @bank_holidays = []
+ @last_checked_at = nil
+ end
+
+ def bank_holidays
+ now = Time.now
+ #
+ # Update the bank holidays list hourly.
+ #
+ if @bank_holidays.nil? or
+ @last_checked_at.nil? or
+ @last_checked_at < (now - 1.hour)
+
+ @bank_holidays = CalendarInterface.get_bank_holiday_list(now)
+ @last_checked_at = now
+ end
+
+ @bank_holidays
+ end
+ end # class BankHolidaysCache
+
+end # module Mauve