Class: Blertr::Notifier

Inherits:
Object
  • Object
show all
Defined in:
lib/blertr/notifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeNotifier

Returns a new instance of Notifier.



7
8
9
10
# File 'lib/blertr/notifier.rb', line 7

def initialize
  @names = []
  @error_messages = []
end

Instance Attribute Details

#error_messagesObject (readonly)

Returns the value of attribute error_messages.



6
7
8
# File 'lib/blertr/notifier.rb', line 6

def error_messages
  @error_messages
end

#namesObject (readonly)

Returns the value of attribute names.



6
7
8
# File 'lib/blertr/notifier.rb', line 6

def names
  @names
end

Instance Method Details

#alert(message) ⇒ Object



39
40
# File 'lib/blertr/notifier.rb', line 39

def alert message
end

#can_alert?Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/blertr/notifier.rb', line 51

def can_alert?
  error_messages << "Unknown Error"
  false
end

#in_time_window?(time) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
49
# File 'lib/blertr/notifier.rb', line 42

def in_time_window? time
  rtn = false
  time_min = options[:time]
  if time_min and time >= time_min
    rtn = true
  end
  rtn
end

#nameObject



12
13
14
# File 'lib/blertr/notifier.rb', line 12

def name
  (!@names or @names.empty?) ? nil : @names[0]
end

#optionsObject



16
17
18
19
# File 'lib/blertr/notifier.rb', line 16

def options
  @options ||= Options::options_for name
  @options
end

#set_option(key, value) ⇒ Object



25
26
27
28
29
# File 'lib/blertr/notifier.rb', line 25

def set_option key, value
  opts = options
  opts[key.to_sym] = value
  Options::save_options_for name, opts
end

#set_time(new_time) ⇒ Object



21
22
23
# File 'lib/blertr/notifier.rb', line 21

def set_time new_time
  set_option :time, new_time
end

#will_alert?(name, time) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
34
35
36
37
# File 'lib/blertr/notifier.rb', line 31

def will_alert? name, time
  rtn = self.can_alert?
  if rtn
    rtn = in_time_window? time
  end
  rtn
end