Class: Cline::Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cline::Notification
- Defined in:
- lib/cline/notification.rb
Class Method Summary collapse
Instance Method Summary collapse
- #detect_url(protocols = %w(http https))) ⇒ Object
- #display! ⇒ Object
- #display_message ⇒ Object
- #id_alias_string ⇒ Object
- #message=(m) ⇒ Object
Class Method Details
.clean(limit) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/cline/notification.rb', line 52 def clean(limit) order('notified_at DESC'). order(:display_count). offset(limit). destroy_all end |
.display!(offset = 0) ⇒ Object
44 45 46 |
# File 'lib/cline/notification.rb', line 44 def display!(offset = 0) earliest(1, offset).first.display! end |
.normalize_message(m) ⇒ Object
48 49 50 |
# File 'lib/cline/notification.rb', line 48 def (m) m.gsub(/[\r\n]/, '') end |
Instance Method Details
#detect_url(protocols = %w(http https))) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/cline/notification.rb', line 72 def detect_url(protocols = %w(http https)) regexp = URI.regexp(protocols) if match = .match(regexp) match.to_s else nil end end |
#display! ⇒ Object
60 61 62 63 64 |
# File 'lib/cline/notification.rb', line 60 def display! .tap { increment! :display_count } end |
#display_message ⇒ Object
66 67 68 69 70 |
# File 'lib/cline/notification.rb', line 66 def display_time = notified_at.strftime('%Y/%m/%d %H:%M') "[#{display_time}][#{display_count}][#{id_alias_string}] #{}" end |
#id_alias_string ⇒ Object
82 83 84 |
# File 'lib/cline/notification.rb', line 82 def id_alias_string id_alias.to_i.to_s(36) end |
#message=(m) ⇒ Object
39 40 41 |
# File 'lib/cline/notification.rb', line 39 def (m) super Notification.(m) end |