Class: BMF::Alert
Instance Method Summary collapse
- #<<(alert) ⇒ Object
- #add_new_messages(i) ⇒ Object
-
#initialize ⇒ Alert
constructor
A new instance of Alert.
- #peek ⇒ Object
- #peek_new_messages ⇒ Object
- #pop ⇒ Object
- #pop_new_messages ⇒ Object
Constructor Details
#initialize ⇒ Alert
Returns a new instance of Alert.
7 8 9 10 |
# File 'lib/bmf/lib/alert.rb', line 7 def initialize @alerts = [] @new_messages = 0 end |
Instance Method Details
#<<(alert) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/bmf/lib/alert.rb', line 12 def << alert Mutex.new.synchronize do if !@alerts.include? alert @alerts << alert end end end |
#add_new_messages(i) ⇒ Object
34 35 36 37 38 |
# File 'lib/bmf/lib/alert.rb', line 34 def i Mutex.new.synchronize do @new_messages += i end end |
#peek ⇒ Object
20 21 22 23 24 |
# File 'lib/bmf/lib/alert.rb', line 20 def peek Mutex.new.synchronize do @alerts.dup.freeze end end |
#peek_new_messages ⇒ Object
40 41 42 43 44 |
# File 'lib/bmf/lib/alert.rb', line 40 def Mutex.new.synchronize do @new_messages end end |
#pop ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/bmf/lib/alert.rb', line 26 def pop Mutex.new.synchronize do alerts = @alerts.dup.freeze @alerts = [] alerts end end |
#pop_new_messages ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/bmf/lib/alert.rb', line 46 def Mutex.new.synchronize do i = @new_messages @new_messages = 0 i end end |