Class: Cline::Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/cline/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clean(pool_size) ⇒ Object



34
35
36
37
38
39
# File 'lib/cline/notification.rb', line 34

def clean(pool_size)
  order_by_default_priority_for_display.
    order('notified_at DESC').
    offset(pool_size).
    destroy_all
end

.display(offset) ⇒ Object



26
27
28
# File 'lib/cline/notification.rb', line 26

def display(offset)
  earliest(1, offset).first.display
end

.normalize_message(m) ⇒ Object



30
31
32
# File 'lib/cline/notification.rb', line 30

def normalize_message(m)
  m.gsub(/[\r\n]/, '')
end

Instance Method Details

#displayObject



42
43
44
45
46
# File 'lib/cline/notification.rb', line 42

def display
  Cline.out_stream.puts display_message

  increment! :display_count
end

#display_messageObject



48
49
50
# File 'lib/cline/notification.rb', line 48

def display_message
  "[#{notified_at}][#{display_count}] #{message}"
end

#message=(m) ⇒ Object



21
22
23
# File 'lib/cline/notification.rb', line 21

def message=(m)
  super Notification.normalize_message(m)
end