aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/notification.rb
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2012-05-02 10:44:34 +0100
committerPatrick J Cherry <patrick@bytemark.co.uk>2012-05-02 10:44:34 +0100
commit27d38820a67751a898d5d17073adc556c4bb56a9 (patch)
tree6157be1229f0c5ea7f8f237370ede914cf7e2f95 /lib/mauve/notification.rb
parente6c1341540eb4c08b1cbfef46cf2360489b27bd0 (diff)
Added configuration options for daytime_hours, dead_zone, and working_hours.
Diffstat (limited to 'lib/mauve/notification.rb')
-rw-r--r--lib/mauve/notification.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/mauve/notification.rb b/lib/mauve/notification.rb
index 899972b..6ff9541 100644
--- a/lib/mauve/notification.rb
+++ b/lib/mauve/notification.rb
@@ -157,6 +157,18 @@ module Mauve
(@test_time - @alert.raised_at) >= seconds
end
+ # Tests if the alert has raised for a certain time.
+ #
+ # @param [Integer] seconds Number of seconds
+ # @return [Boolean]
+ def raised_for(seconds)
+ @test_time = @time if @test_time.nil?
+ @alert &&
+ @alert.raised? &&
+ (@test_time - @alert.raised_at) >= seconds
+ end
+
+
# Checks to see if x is contained in y
#
# @param [Array] y Array to search for +x+
@@ -177,10 +189,17 @@ module Mauve
# @return [Boolean]
def working_hours?
@test_time = @time if @test_time.nil?
- @test_time.bank_holidays = Server.instance.bank_holidays
@test_time.working_hours?
end
+ #
+ # Return true if today is a bank holiday
+ #
+ def bank_holiday?
+ @test_time = @time if @test_time.nil?
+ @test_time.bank_holiday?
+ end
+
# Test to see if we're in the dead zone. See Time#dead_zone?
#
# @return [Boolean]
@@ -189,6 +208,13 @@ module Mauve
@test_time.dead_zone?
end
+ #
+ # Return true if we're in daytime_hours. See Time#daytime_hours?
+ #
+ def daytime_hours?
+ @test_time = @time if @test_time.nil?
+ @test_time.daytime_hours?
+ end
end
# A Notification is an instruction to notify a person, or a list of people,